Socket
Socket
Sign inDemoInstall

clipboard-text

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    clipboard-text

Simple and small copy-text-to-the-clipboard-utility with IE11 support


Version published
Weekly downloads
23
increased by35.29%
Maintainers
1
Install size
5.54 kB
Created
Weekly downloads
 

Readme

Source

clipboard-text Build Status npm package

Simple and small copy-text-to-the-clipboard-utility with IE11 support

Installation

npm install clipboard-text

Usage

import copy from 'clipboard-text'

button.addEventListener('click', () => {
  copy('Hi there')
})

API

copy(text: string, parentElement?: Element): boolean

Copy text to the clipboard.

If the event triggering the copy functions comes from an element with a focus trap, like a Modal, you will need to provide a parentElement. By default, parentElement is set to body.

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.

  • copy-text-to-clipboard - Original package with no support for IE and no support for focus traps

License

MIT

Keywords

FAQs

Last updated on 27 May 2021

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc