Share Sheet
Share a link anywhere: copy it, send it to email or a network, scan it as a QR code, or hand it to the device’s own share sheet.
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
url | string | — | What is shared. Only an http(s) link is offered to the targets. |
heading | string | — | The name of what is shared, for the heading and the targets that take a title. |
text | string | — | Text that goes with the link, where the target takes text (a post, a message, an email body). |
targets | string[] | DEFAULT_TARGETS | The targets, ;-separated: email, sms, x, linkedin, facebook, whatsapp, telegram, reddit. |
qr | boolean | false | Shows a QR code of the link. |
open | boolean | false | Whether the sheet is open. |
side | 'top' | 'right' | 'bottom' | 'left' | bottom | The edge the sheet comes from, as c2-sheet's side. |
Slots
| Name | Description |
|---|---|
icon-linkedin | Artwork for a target, in place of its tile. Likewise icon-email, icon-sms, icon-x, icon-facebook, icon-whatsapp, icon-telegram, icon-reddit and icon-native. |
Events
| Name | Type | Description |
|---|---|---|
share | CustomEvent<{ target: 'copy' | 'email' | 'sms' | 'x' | 'linkedin' | 'facebook' | 'whatsapp' | 'telegram' | 'reddit' | 'native'; url: string }> | Cancelable. Fired before a target opens, and after the link is copied (target copy). |
open | Event | Fired after the sheet has opened. |
close | Event | Fired after the sheet has closed. |
CSS parts
Shadow DOM styling hooks used with ::part(name). Prefer CSS custom properties when they cover the change.
| Name | Description |
|---|---|
link | The read-only link field. |
targets | The row of targets. |
target | One target. |
tile | A target's round tile. |
qr | The QR code. |
CSS custom properties
Grouped by semantic target and state from --c2-<component>__<target>__<state>--<property>. Click a group to collapse it; click a name to copy it.
| Name | Type | Default | Description |
|---|---|---|---|
--c2-share-sheet--gap | pixel | 20px | Space between the link, the targets and the QR code. |
--c2-share-sheet__link--background | color | #f4f4f5 | |
--c2-share-sheet__link--color | color | #3f3f46 | |
--c2-share-sheet__link--border-radius | border-radius | 8px | |
--c2-share-sheet__tile--size | pixel | 48px | |
--c2-share-sheet__tile--background | color | #f4f4f5 | |
--c2-share-sheet__tile--color | color | #18181b | |
--c2-share-sheet__tile__hover--background | color | #e4e4e7 | |
--c2-share-sheet__label--font-size | font-size | 12px | |
--c2-share-sheet__label--color | color | #52525b | |
--c2-share-sheet__qr--size | pixel | 160px | |
--c2-share-sheet__focus--outline | outline | 2px solid rgba(2, 101, 220, 0.4) | |
Text and languages
The text the component shows, in English. It shows another language when the app adds one with addTranslations, under share-sheet, and the nearest lang asks for it; any message not translated stays in English. {0}, {1}… stand for the values a message carries. Languages guide.
| Key | English | Values |
|---|---|---|
heading | Share “{0}” | {0} name |
link | Link | — |
copy | Copy link | — |
copied | Copied | — |
targets | Share to | — |
shareOn | Share on {0} | {0} name |
email | — | |
sms | Message | — |
more | More | — |
shareByEmail | Share by email | — |
shareBySms | Share by text message | — |
moreOptions | More sharing options | — |
qr | QR code for {0} | {0} url |