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 item for the canonical URL or text payload.

  • subject and message map 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

PropTypeRequiredDescription
itemstringYesThe item to share. A string URL is treated as the shared URL on the web.
subjectstringNoOptional subject/title passed to the share sheet.
messagestringNoOptional supporting message/text passed to the share sheet.

Inherits additional props from Omit<IBaseElementComponent<'button'>, 'type'>.