# svelte-copy-to-clipboard

> Copy to clipboard component for Svelte

Latest version **0.2.5** (published 2020-05-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install svelte-copy-to-clipboard
pnpm add svelte-copy-to-clipboard
yarn add svelte-copy-to-clipboard
bun add svelte-copy-to-clipboard
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.5 |
| Published | 2020-05-25 |
| First published | 2020-01-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Henrique Araujo |
| Maintainers | henriquecaraujo |
| Keywords | svelte, copy, clipboard |

## Links

- npm: https://www.npmjs.com/package/svelte-copy-to-clipboard
- Issues: https://github.com/henriquecaraujo/svelte-copy-to-clipboard/issues
- npm.io page: https://npm.io/package/svelte-copy-to-clipboard

## Recent versions

- 0.2.5 (latest) — 2020-05-25
- 0.2.4 — 2020-04-24
- 0.2.2 — 2020-04-24
- 0.2.0 — 2020-02-01
- 0.1.1 — 2020-01-31
- 0.1.0 — 2020-01-31

## README

![Svelte Copy to Clipboard](./docs/header.png)

[![npm version](https://badge.fury.io/js/svelte-copy-to-clipboard.svg)](https://badge.fury.io/js/svelte-copy-to-clipboard)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Build Status](https://travis-ci.com/henriquecaraujo/svelte-copy-to-clipboard.svg?branch=master)](https://travis-ci.com/henriquecaraujo/svelte-copy-to-clipboard)

## Installation

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

[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
<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](https://nodei.co/npm/svelte-copy-to-clipboard.png)](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).

---
_Source: https://npm.io/package/svelte-copy-to-clipboard · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
