An element that copies a text to clipboard

Usage no npm install needed!

<script type="module">
  import advancedRestClientClipboardCopy from 'https://cdn.skypack.dev/@advanced-rest-client/clipboard-copy';


Published on NPM

Build Status

Published on webcomponents.org


An element that copies a text to clipboard.

API components

This components is a part of API components ecosystem



npm install --save @advanced-rest-client/clipboard-copy

In an html file

<script type="module" src="/node_modules/@advanced-rest-client/clipboard-copy/clipboard-copy.js"></script>
<clipboard-copy content="test"></clipboard-copy>
const elm = document.querySelectior('clipboard-copy');
if(elm.copy()) {
 console.info('Content has been copied to the clipboard');
} else {
 console.error('Content copy error. This browser is ancient!');

In a LitElement

import { LitElement, html } from 'lit-element';
import '@advanced-rest-client/clipboard-copy/clipboard-copy.js';

class SampleElement extends LitElement {
  render() {
    return html`
    <clipboard-copy .content="${this.copyContent}"></clipboard-copy>
customElements.define('sample-element', SampleElement);


git clone https://github.com/advanced-rest-client/clipboard-copy
cd clipboard-copy
npm install

Running the demo locally

npm start

Running the tests

npm test