0.2.5 • Published 4 years ago

svelte-copy-to-clipboard v0.2.5

Weekly downloads
78
License
MIT
Repository
-
Last release
4 years ago

Svelte Copy to Clipboard

npm version License: MIT Build Status

Installation

npm i svelte-copy-to-clipboard
// OR
yarn add svelte-copy-to-clipboard

LIVE DEMO

Local demo:

git clone https://github.com/henriquecaraujo/svelte-copy-to-clipboard.git
cd svelte-copy-to-clipboard
yarn && yarn dev

Examples

<script>
  import CopyToClipboard from "svelte-copy-to-clipboard";
  let exampleText = 'Copy me!';

  const handleSuccessfullyCopied = (e) => {
      alert(`successfully copied to clipboard! ${e}`);
  }

  const handleFailedCopy = () => {
      alert('failed to copy :(');
  }
</script>

<CopyToClipboard text={exampleText} on:copy={handleSuccessfullyCopied} on:fail={handleFailedCopy} let:onCopy>
    <button on:click={onCopy}>An element to trigger the copy</button>
</CopyToClipboard>

Properties

Component props:

PropTypeDescription
textstringValue to copy
copyfuncCall when text's copied
failfuncCall when copy fails

Slot Properties

PropTypeDescription
onCopystringCall foi copy

NPM Statistics

Download stats for this NPM package

NPM

License

Svelte Copy to Clipboard is open source software licensed as MIT.