2015-09-18 17:30:12 -07:00
2015-09-17 23:15:24 -07:00
2015-09-17 23:16:08 -07:00
2015-09-18 15:55:18 -07:00
2015-09-18 15:55:18 -07:00

clipboard.js

A modern approach to copy & cut to the clipboard. No Flash. No dependencies. Just 1kb.

Install

You can get it using bower:

bower install clipboard --save

Or download as ZIP.

Usage

First, you need to instantiate it using a selector. This selector corresponds to the trigger element (usually a <button>).

new Clipboard('.btn');

The easiest way to copy some content to the clipboard, is to include a value attribute in your trigger element.

<button class="btn" value="lorem ipsum">Copy</button>

Another way of doing it is to copy the content from an <input> or <textarea>. You can do that by adding a for attribute in your trigger element. The value you include in this for attribute needs to match another's element id attribute.

<input id="target" value="Lorem ipsum">
<button class="btn" for="target">Copy</button>

Browser Support

This project relies on both Select API and execCommand API. When combined, they're supported in the following browsers.

Chrome logo Firefox logo Internet Explorer logo Opera logo Safari logo
42+ ✔ 41+ ✔ 9+ ✔ 29+ ✔ Nope ✘

License

MIT License © Zeno Rocha

Description
✂️ Modern copy to clipboard. No Flash. Just 3kb gzipped 📋
https://clipboardjs.com Readme 8.1 MiB
Languages
JavaScript 99.1%
TypeScript 0.6%
Shell 0.3%