InspectionCleaning/node_modules/copy-text-to-clipboard
陆亚狮 b57100d301 - 2025-04-07 09:53:58 +08:00
..
index.d.ts - 2025-04-07 09:53:58 +08:00
index.js - 2025-04-07 09:53:58 +08:00
license - 2025-04-07 09:53:58 +08:00
package.json - 2025-04-07 09:53:58 +08:00
readme.md - 2025-04-07 09:53:58 +08:00

readme.md

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.

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