|
il y a 1 an | |
---|---|---|
.. | ||
index.d.ts | il y a 1 an | |
index.js | il y a 1 an | |
license | il y a 1 an | |
package.json | il y a 1 an | |
readme.md | il y a 1 an |
Copy text to the clipboard in modern browsers (0.2 kB)
clipboard.js
: 3.4 kBnpm install copy-text-to-clipboard
import copy from 'copy-text-to-clipboard';
button.addEventListener('click', () => {
copy('🦄🌈');
});
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
.
Type: object
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.