Skip to content
/ clipbrd Public

Lightweight copy to clipboard for modern browsers

License

Notifications You must be signed in to change notification settings

shrpne/clipbrd

Repository files navigation

clipbrd

NPM Package Minified Size Build Status License: MIT

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

Demo JSFiddle

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

About

Lightweight copy to clipboard for modern browsers

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published