Launch Week Day 1: Socket for Jira Is Now Available.Learn More
Socket
Book a DemoSign in
Socket

copy-text-to-clipboard

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

copy-text-to-clipboard

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

latest
Source
npmnpm
Version
3.2.2
Version published
Weekly downloads
687K
6.74%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

copy

FAQs

Package last updated on 23 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts