Calm motion: animations on this site only fade, with no movement
Share bar
Share a page through the Web Share API, with copy link as a fallback
Lets a reader share an article, an episode, or a product. On phones and some desktop browsers, it opens the share sheet of the system.
Basic
vue
<template>
<BlessShareBar
:url
title="Episode 41: the final edit"
:targets="[
{ label: 'Email', href: `mailto:?subject=Episode%2041&body=${encodeURIComponent(url)}` },
]"
@shared="(how) => (last = how)"
/>
<p v-if="last" style="margin-top: 12px">Shared by: {{ last }}</p>
</template>
<script setup lang="ts">
import { ref } from "vue";
import { BlessShareBar } from "blessing-ui";
const url = "https://example.com/episodes/41";
const last = ref("");
</script>urlis the page to share, andtitleis its title.- If the browser has the Web Share API, a "Share…" button opens the share sheet of the system. The button shows after the page loads, because only the browser knows.
- "Copy link" copies the address. A hidden status line then says "Link copied", and the button says it too.
targetsis a list of your own share links, each with alabeland anhref. The bar has no built-in services, so you choose which ones to show and you write their links.- Each share emits
sharedwith how:system,copy, or the label of the target. - Change the words with
labelsor a label pack:title,share,copy, andcopied.
Usage
ts
import { BlessShareBar } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
url* | string | — | the page to share |
title | string | — | |
targets | BlessShareTarget[] | — | share links of the services you choose |
labels | Partial<{ title: string; share: string; copy: string; copied: string; }> | — |
Events
| Name | Payload | Description |
|---|---|---|
shared | [how: string] |