clipbrd

1.0.2 • Public • Published

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

Dependencies (0)

    Dev Dependencies (11)

    Package Sidebar

    Install

    npm i clipbrd

    Weekly Downloads

    344

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    9.44 kB

    Total Files

    8

    Last publish

    Collaborators

    • shrpne