@saekitominaga/customelements-button-share

Share button by Custom Elements.

Usage no npm install needed!

<script type="module">
  import saekitominagaCustomelementsButtonShare from 'https://cdn.skypack.dev/@saekitominaga/customelements-button-share';
</script>

README

Share button by Custom Elements.

npm version

Share button using Web Share API by Custom Elements.

Demo

Examples

<button type="button" is="x-share"
  data-share-text="Message text"
  data-share-title="Page title"
  data-share-url="/path/to"
>Share</button>

Attributes

type [optional]
This function automatically sets type="button". However, it is recommended to manually add type="button" for JavaScript disabled environments and browsers that do not support Customized built-in elements (Safari 14, Edge Legacy, etc.). According to the description in the HTML specification, The missing value default and invalid value default are the Submit Button state.
data-share-text [optional]
Arbitrary text that forms the body of the message being shared. If omitted, it will be an empty string.
data-share-title [optional]
The title of the document being shared. May be ignored by the target. If omitted, the value of document.title will be set.
data-share-url [optional]
A URL string referring to a resource being shared. The url can contain a relative-URL string. If omitted, the value of document.URL will be set.