copy-text-to-clipboard

Copy text to the clipboard in modern browsers (0.2 kB)

copy-text-to-clipboard downloads copy-text-to-clipboard version copy-text-to-clipboard license

copy-text-to-clipboardSimilar Packages:
Npm Package Weekly Downloads Trend
3 Years
🌟 Show real-time usage chart on copy-text-to-clipboard's README.md, just copy the code below.
## Usage Trend
[![Usage Trend of copy-text-to-clipboard](https://npm-compare.com/img/npm-trend/THREE_YEARS/copy-text-to-clipboard.png)](https://npm-compare.com/copy-text-to-clipboard#timeRange=THREE_YEARS)
Cumulative GitHub Star Trend
🌟 Show GitHub stars trend chart on copy-text-to-clipboard's README.md, just copy the code below.
## GitHub Stars Trend
[![GitHub Stars Trend of copy-text-to-clipboard](https://npm-compare.com/img/github-trend/copy-text-to-clipboard.png)](https://npm-compare.com/copy-text-to-clipboard)
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
copy-text-to-clipboard498,5071,0395.6 kB1a month agoMIT
README for copy-text-to-clipboard

copy-text-to-clipboard

Copy text to the clipboard in modern browsers (0.2 kB)

Try it out!

Comparison

Install

npm install copy-text-to-clipboard

Usage

import copy from 'copy-text-to-clipboard';

button.addEventListener('click', () => {
	copy('🦄🌈');
});

API

copy(text, options?)

Copy text to the clipboard.

Returns a boolean of whether it succeeded to copy the text.

Must be called in response to a user gesture event, like click or keyup.

options

Type: object

target

Type: HTMLElement
Default: document.body

Specify a DOM element where the temporary, behind-the-scenes textarea should be appended, in cases where you need to stay within a focus trap, like in a modal.

Related

  • clipboardy - Access the system clipboard (copy/paste) in Node.js