Methane@methane-ui/*
CSS LayoutsComponentsSkillsTheme BuilderGitHub
← All Components

<mth-share-button>

@methane-ui/ui~6.8 KB brotli (cold + Lit)~1.4 KB marginal

Web 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.

Live Interactive Preview

Interactive StageLive Custom Element · <mth-share-button> (@methane-ui/ui)
Ready · interact with <mth-share-button>, or toggle Theme, Direction (LTR/RTL), or props above.

Multi-Framework Playground & Snippets

<script type="module" src="@methane-ui/ui/share-button"></script>
<mth-share-button variant="solid" size="sm">Example</mth-share-button>

Properties & Attributes

PropertyAttributeTypeDefaultDescription
shareTitleshare-titlestring""Title passed to navigator.share.
texttextstring""Descriptive share body text.
urlurlstring""Safe URL to share (rejects unsafe protocols like javascript: or data:).
variantvariant'solid' | 'outline' | 'ghost'"outline"Button visual style (solid, outline, or ghost).
sizesize'sm' | 'md' | 'lg'"md"Control size (sm, md, or lg).
disableddisabledbooleanfalseDisables interaction.
feedbackDurationfeedback-durationnumber2000Duration in ms to show shared feedback state.
labellabelstring""Accessible aria-label when idle.
sharedLabelshared-labelstring""Accessible label/announcement text after sharing.

Events

EventDetail TypeDescription
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

KeyDirectionWhenExpected Behavior
EnterbothButton is focused and enabledInvokes Web Share API or clipboard fallback and emits mth-share
bothButton is focused and enabledInvokes Web Share API or clipboard fallback and emits mth-share

Accessibility Checklist

CategoryRequirementVerified By
ariaAll aria-* IDREFs resolve within the same DOM root (ADR-003).scanSameRootAria
focusdelegatesFocus: true with zero host internals.role (ADR-014).lint-plugin & spec-compiler
contrastRenders legible borders, focus outlines, and selection indicators under forced-colors: active.Playwright forced-colors matrix
keyboardImplements all 2 APG keyboard transitions across LTR/RTL.mth-share-button.spec.test.ts
statesExposes ElementInternals CustomStateSet flags: :state(shared), :state(disabled).Conformance suite
i18nRoutes 2 UI/ARIA strings through @methane-ui/core i18n catalog.Locale context test