• Version 2.0.11
  • Published
  • 94.5 kB
  • 3 dependencies
  • MIT license


npm i clipboard
yarn add clipboard
pnpm add clipboard


Modern copy to clipboard. No Flash. Just 2kb



class ClipboardJS

class ClipboardJS {}
  • Base class which takes one or more elements, adds event listeners to them, and instantiates a new ClipboardAction on each click.


selector: string | Element | NodeListOf<Element>,
options?: ClipboardJS.Options

    method copy

    static copy: (target: string | Element, options?: CopyActionOptions) => string;
    • Fires a copy action

    method cut

    static cut: (target: string | Element) => string;
    • Fires a cut action

    method destroy

    destroy: () => void;
    • Clears all event bindings.

    method isSupported

    static isSupported: () => boolean;
    • Checks if clipboard.js is supported

    method on

    on: {
    (type: Response, handler: (e: ClipboardJS.Event) => void): this;
    (type: string, handler: (...args: any[]) => void): this;
    • Subscribes to events that indicate the result of a copy/cut operation.

      Parameter type

      Event type ('success' or 'error').

      Parameter handler

      Callback function.


    interface Event

    interface Event {}

      property action

      action: string;

        property text

        text: string;

          property trigger

          trigger: Element;

            method clearSelection

            clearSelection: () => void;

              interface Options

              interface Options {}

                property container

                container?: Element;
                • For use in Bootstrap Modals or with any other library that changes the focus you'll want to set the focused element as the container value.

                method action

                action: (elem: Element) => Action;
                • Overwrites default command ('cut' or 'copy').

                  Parameter elem

                  Current element

                method target

                target: (elem: Element) => Element;
                • Overwrites default target input element.

                  Parameter elem

                  Current element


                  element to use.

                method text

                text: (elem: Element) => string;
                • Returns the explicit text to copy.

                  Parameter elem

                  Current element


                  Text to be copied.

                Package Files (1)

                Dependencies (3)

                Dev Dependencies (25)

                Peer Dependencies (0)

                No peer dependencies.


                To add a badge like this badgeto your package's README, use the codes available below.

                You may also use to create a custom badge linking to

                • Markdown
                • HTML
                  <a href=""><img src="" alt=""></a>