@methane-ui/ui~6.8 KB brotli (cold + Lit)~1.4 KB marginalWeb Share API trigger button with automatic safe-URL validation and clipboard fallback.
When NOT to use: Use a lightweight @methane-ui/css layout class instead of a custom element when static CSS suffices.
Multi-Framework Playground & Snippets
Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|
shareTitle | share-title | string | "" | Title passed to navigator.share. |
text | text | string | "" | Descriptive share body text. |
url | url | string | "" | Safe URL to share (rejects unsafe protocols like javascript: or data:). |
variant | variant | 'solid' | 'outline' | 'ghost' | "outline" | Button visual style (solid, outline, or ghost). |
size | size | 'sm' | 'md' | 'lg' | "md" | Control size (sm, md, or lg). |
disabled | disabled | boolean | false | Disables interaction. |
feedbackDuration | feedback-duration | number | 2000 | Duration in ms to show shared feedback state. |
label | label | string | "" | Accessible aria-label when idle. |
sharedLabel | shared-label | string | "" | Accessible label/announcement text after sharing. |
Events
| Event | Detail Type | Description |
|---|
mth-share | { method: string; title?: string; text?: string; url?: string } | Fired after sharing succeeds via Web Share or clipboard fallback. |
mth-share-error | { reason: string } | Fired if sharing fails or payload URL is unsafe/empty. |
APG Keyboard Matrix
| Key | Direction | When | Expected Behavior |
|---|
| Enter | both | Button is focused and enabled | Invokes Web Share API or clipboard fallback and emits mth-share |
| | both | Button is focused and enabled | Invokes Web Share API or clipboard fallback and emits mth-share |
Accessibility Checklist
| Category | Requirement | Verified By |
|---|
| aria | All aria-* IDREFs resolve within the same DOM root (ADR-003). | scanSameRootAria |
| focus | delegatesFocus: true with zero host internals.role (ADR-014). | lint-plugin & spec-compiler |
| contrast | Renders legible borders, focus outlines, and selection indicators under forced-colors: active. | Playwright forced-colors matrix |
| keyboard | Implements all 2 APG keyboard transitions across LTR/RTL. | mth-share-button.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(shared), :state(disabled). | Conformance suite |
| i18n | Routes 2 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |