Web component to use the Web Share API, with a fallback to copy to the clipboard.
npm install @zachleat/webcare-webshare Web ComponentA web component that uses the Web Share API to share a web site, falling back (on Desktop usually) to Copy to Clipboard.
* Demos
Used on the registration flow for conf.11ty.dev.
* Defaults to copy URL when Web Share API is not available.
* Optionally override with your own copy-able content.
* Custom button text when Web Share API is not available.
You can install via npm (@zachleat/webcare-webshare) or download the webcare-webshare.js JavaScript file manually.
``shell`
npm install @zachleat/webcare-webshare --save
Add webcare-webshare.js to your site’s JavaScript assets.
Use share-text and share-url per the Web Share API. The button is un-disabled when initialized.
`html`
_Copy to clipboard_ workflow only. Use the label-copy (Before) and label-after-copy (After) attributes.
`html`
_Copy to clipboard_ workflow only. Use copy-text to override share-url as the default content that is copied when using Copy to Clipboard.
`html``