Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ghostdevv/svelte-copy
A svelte action to copy text on click!
https://github.com/ghostdevv/svelte-copy
hacktoberfest svelte sveltejs
Last synced: 4 days ago
JSON representation
A svelte action to copy text on click!
- Host: GitHub
- URL: https://github.com/ghostdevv/svelte-copy
- Owner: ghostdevv
- License: mit
- Created: 2021-12-07T14:02:26.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-11-25T16:13:36.000Z (about 1 month ago)
- Last Synced: 2024-12-14T21:02:25.706Z (11 days ago)
- Topics: hacktoberfest, svelte, sveltejs
- Language: TypeScript
- Homepage: https://svelte-copy.willow.codes
- Size: 373 KB
- Stars: 163
- Watchers: 3
- Forks: 9
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Svelte Copy
A svelte action to copy text to clipboard. It uses the `navigator.clipboard` api, with a fallback to the legacy method.
# Installing
```sh
npm install svelte-copy -D
```This library only works with Svelte 5, checkout [svelte-copy@1](https://www.npmjs.com/package/svelte-copy/v/1.4.2) for Svelte 3/4 support.
# Usage
The simplest use is to just pass the text you want to copy:
```svelte
import { copy } from 'svelte-copy';
Click me!
```
You can expand that with an options object:
```svelte
import { copy } from 'svelte-copy';
Copy
```
[Read the full docs here](https://svelte-copy.willow.codes).
# Migrating from v1 to v2
- The `on:svelte-copy` event is now a `onCopy` param to the action options.
- The `on:svelte-copy:error` event is now a `onError` param to the action options.
- The `events` option now only accepts `string[]`, rather than `string | string[]`
- Svelte 5 is now required# Support
- Join the [discord](https://discord.gg/2Vd4wAjJnm)
- Create a issue on the [github](https://github.com/ghostdevv/svelte-copy)