Skip to content
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
Email
  • url is the page to share, and title is 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.
  • targets is a list of your own share links, each with a label and an href. The bar has no built-in services, so you choose which ones to show and you write their links.
  • Each share emits shared with how: system, copy, or the label of the target.
  • Change the words with labels or a label pack: title, share, copy, and copied.

Usage ​

ts
import { BlessShareBar } from "blessing-ui";

API ​

Props

NameTypeDefaultDescription
url*string—the page to share
titlestring—
targetsBlessShareTarget[]—share links of the services you choose
labelsPartial<{ title: string; share: string; copy: string; copied: string; }>—

Events

NamePayloadDescription
shared[how: string]

Released under the MIT License. Character names and artwork belong to their owners.