Actions
ShareButton <pm-share-button>
Share button: opens the device's share sheet (phones, Safari, Edge) and copies the link where there is none.
Variants
Set with the variant attribute.
variant="solid"variant="soft"variant="outline"variant="ghost"Sizes
Set with the size attribute; controls keep touch-sized targets on phones.
size="xs"size="sm"size="md"size="lg"Tones
Set tone on the element, or data-tone on any ancestor to tone a whole area.
tone="accent"tone="secondary"tone="neutral"tone="success"tone="warning"tone="danger"tone="info"States
Each state is one attribute.
DisabledOverview
The page address is shared unless url is set. After a copy the button says so, visibly and to screen readers.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
url | string | — | Address to share (default: this page). |
share-titleprop: shareTitle | string | — | Title passed to the share sheet (default: the page title). |
text | string | — | Short text passed to the share sheet. |
label | string | Share | Button text (default "Share"). |
variant | 'solid' | 'soft' | 'outline' | 'ghost' | — | Visual style. |
size | 'xs' | 'sm' | 'md' | 'lg' | — | Size: xs, sm, md or lg (md when not set). |
icon-onlyprop: iconOnly | boolean | false | Show only the icon; the label becomes the accessible name. |
disabled | boolean | false | Not interactive. |
Also accepts the contextual attributes tone, surface, radius, density, motion, elevation. They are inherited from ancestors' data-* attributes.
Events
| Event | React / Svelte prop | Description |
|---|---|---|
pm-share | onPmShare | Shared or copied. |
pm-error | onPmError | Sharing and copying both failed. |
CSS parts
| Part | Description |
|---|---|
::part(base) | The button. |
Methods
share()