clipbrd

v1.0.2
Lightweight copy to clipboard for modern browsers
clipboard copy support browser

clipbrd

NPM Package Minified Size License: MIT

Lightweight module to copy text to the clipboard in modern browsers (< 1kB minified)

Install

npm install clipbrd

Usage

import * as clipboard from 'clipbrd';

if (clipboard.isSupported()) {
    button.addEventListener('click', () => {
        clipboard.copy('Custom text');
    });
}

API

copy(text)

Copy text to the clipboard.

Returns a boolean of whether it succeeded.

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

isSupported()

Check if copy is supported, that way you can hide copy buttons from the UI.

Returns a boolean

Reference

License

MIT License

npm i clipbrd

Metadata

  • MIT
  • Whatever
  • shrpne
  • released 7/26/2018

Downloads

Maintainers