svelte-copy-to-clipboard

0.2.5 • Public • Published

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:

Prop Type Description
text string Value to copy
copy func Call when text's copied
fail func Call when copy fails

Slot Properties

Prop Type Description
onCopy string Call foi copy

NPM Statistics

Download stats for this NPM package

NPM

License

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

Readme

Keywords

Package Sidebar

Install

npm i svelte-copy-to-clipboard

Weekly Downloads

858

Version

0.2.5

License

MIT

Unpacked Size

9.47 kB

Total Files

6

Last publish

Collaborators

  • henriquecaraujo