Components
ShareLink
ShareLink presents a platform share action. On the web it uses the Web Share API when available and falls back to opening shareable URLs.
Example
Requires React 18.2+ or 19 and shared styles. See setup.
Default
Loading preview…
Code
'use client';
import { ShareLink } from '@swiftuijs/ui';
export default function Example() {
return (<ShareLink item="https://swiftuijs.evecalm.com/docs" subject="SwiftUI.js" message="Take a look">Share docs</ShareLink>);
}Usage and limitations
-
Use
itemfor the canonical URL or text payload. -
subjectandmessagemap to the web share title and text fields. -
Web Share and clipboard fallback depend on browser support, a secure context and a user gesture. HTTP(S) URLs open in a new tab when Web Share is unavailable; non-URL text uses the clipboard when available. Applications should handle share rejection/cancellation.
API reference
| Prop | Type | Required | Description |
|---|---|---|---|
item | string | Yes | The item to share. A string URL is treated as the shared URL on the web. |
subject | string | No | Optional subject/title passed to the share sheet. |
message | string | No | Optional supporting message/text passed to the share sheet. |
Inherits additional props from Omit<IBaseElementComponent<'button'>, 'type'>.