Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bodjay/svelte-copy-to-clipboard
A flexible copy to clipboard component for Svelte
https://github.com/bodjay/svelte-copy-to-clipboard
Last synced: 4 months ago
JSON representation
A flexible copy to clipboard component for Svelte
- Host: GitHub
- URL: https://github.com/bodjay/svelte-copy-to-clipboard
- Owner: bodjay
- License: mit
- Created: 2020-01-31T02:38:38.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-02-01T23:03:30.000Z (about 1 year ago)
- Last Synced: 2024-10-28T16:23:03.761Z (4 months ago)
- Language: JavaScript
- Homepage: https://svelte-copy-to-clipboard.netlify.com/
- Size: 3.52 MB
- Stars: 24
- Watchers: 1
- Forks: 7
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-svelte - Svelte Copy to Clipboard - Componente para realizar cópia de textos. (UI Componentes / Comunidade Global)
README

[](https://badge.fury.io/js/svelte-copy-to-clipboard)
[](https://opensource.org/licenses/MIT)
[](https://travis-ci.com/henriquecaraujo/svelte-copy-to-clipboard)## Installation
```
npm i svelte-copy-to-clipboard
// OR
yarn add svelte-copy-to-clipboard
```Note: to use this library in sapper, install as devDependency. See the [link](https://github.com/sveltejs/sapper-template#using-external-components).
[LIVE DEMO](https://svelte-copy-to-clipboard.netlify.com/)
Local demo:
```
git clone https://github.com/henriquecaraujo/svelte-copy-to-clipboard.git
cd svelte-copy-to-clipboard
yarn && yarn dev
```## Examples
```js
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 :(');
}An element to trigger the copy
```
## 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
[](https://nodei.co/npm/svelte-copy-to-clipboard/)
## License
Svelte Copy to Clipboard is open source software [licensed as MIT](https://github.com/henriquecaraujo/svelte-copy-to-clipboard/blob/master/LICENSE).