@slushman/share-button

v1.1.0

Published

An HTML button that opens a native share sheet or copies the sharing message to your clipboard.

Downloads

9

Readme

@slushman/share-button

An HTML button that opens a native share sheet or copies the sharing message to your clipboard.

Installation

Install with your preferred package manager.

yarn add @slushman/share-button
or
npm install @slushman/share-button

Dependencies

  • React
  • css.gg
  • Tailwind

Example usage

import { ShareButton } from "@slushman/share-button";

<ShareButton
  shareContent="Example share content that can be as long as you prefer."
  shareTitle="Example Title"
/>;

Props

classes

Optional object to customize the Tailwind classes on each element. The options are:

  • button
  • icon

buttonLabel

Optional label for the button. The default value is 'Share'.

onCopyToClipboard

Optional function that runs if the device does not have a native share sheet. In this case, the shareContent is copied to the clipboard, then this function runs.

onNoShare

Optional function that runs if the device does not neither a native share sheet nor a cliboard.

shareContent

Required string. The content shared in the share sheet or clipboard.

shareTitle

Required string. The title used for the share sheet.