Skip to content

ShareSheet ​

A share panel that rises from the bottom: heading + channel grid + cancel button. Channels are declared through the channels JSON attribute ([{ key, name, icon? }]); icon is an oas-icon name (built-in or host-registered). Clicking a channel dispatches oas-select and closes the panel automatically.

  • The open attribute is controlled; show() / close() offer programmatic control
  • Heading / cancel / close copy comes from i18n and can be overridden with heading / cancel-text
  • Opening moves focus to the first channel; Tab cycles inside the panel, Esc closes, and focus returns to the previously focused element
  • role="dialog" + aria-modal="true", with the heading as the accessible name

Basic Usage ​

Open via button (with channel / close feedback)

Open share sheetNo channel selected yet

Custom Heading / Cancel Text ​

description renders a descriptive line under the heading (share notes and the like); it is not rendered by default:

heading / description / cancel-text overrides

Open custom sheet

Channel Descriptions ​

channels[].description renders a small description under each channel name (what the channel does); it is not rendered by default:

channels[].description

Open sheet with channel descriptions

Channels Without Icons ​

When icon is missing, the first character of the name is used as a placeholder — handy for channels whose icons are not registered:

No icon → initial placeholder

Open iconless sheet

Events ​

oas-select (detail { key, name, channel }) fires when a channel is clicked; oas-close (detail { reason, key? }) fires on close, where reason is select / cancel / close / backdrop / esc / api.

js
sheet.addEventListener('oas-select', (e) => console.info(e.detail.key))
sheet.addEventListener('oas-close', (e) => console.info(e.detail.reason))

API ​

oas-share-sheet ​

Attributes ​

AttributeDescriptionTypeDefault
cancel-textCancel button copy; defaults to i18n shareSheet.cancelstring—
channelsChannel JSON array [{ key, name, icon? }]: icon is an oas-icon name; missing icons fall back to the first character; invalid JSON is ignored with one dev warningShareSheetChannel[] | string—
descriptionDescriptive line under the heading (share notes and the like; not rendered by default)string—
headingPanel heading; defaults to i18n shareSheet.titlestring—
openControlled visibility (present = open; host writes are silent)——

Property (JS property; see each row for attribute reflection) ​

PropertyDescriptionTypeDefault
channelsChannel list (property channel): equals the parsed channels attribute; assigning an array serializes and reflects it back to the attributeShareSheetChannel[] | string—

Methods ​

MethodSignatureDescription
showshow(): voidOpen the sheet (writes the open attribute)
closeclose(reason: CloseReason): voidClose the sheet and dispatch oas-close (reason defaults to api)

Events ​

EventDescription
oas-closeDispatched on close (reason: select / cancel / close / backdrop / esc / api), detail: key === undefined ? { reason } : { reason, key }
oas-selectDispatched when a channel is clicked; the sheet then closes automatically, detail: { key: channel.key, name: channel.name, channel }

CSS Variables ​

CSS VariableDescriptionDefault
--oas-share-sheet-bgPanel backgroundvar(--oas-color-bg)
--oas-share-sheet-channel-bgChannel icon backgroundvar(--oas-color-bg-elevated)
--oas-share-sheet-channel-colorChannel icon foregroundvar(--oas-color-text-primary)
--oas-share-sheet-colorPanel text colorvar(--oas-color-text-primary)
--oas-share-sheet-columnsGrid column count4
--oas-share-sheet-maskMask colorvar(--oas-color-overlay)
--oas-share-sheet-max-heightPanel max height80vh

Released under the MIT OR Apache-2.0 License.