JSPM

clipboard-text

2.0.0
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 16
    • Score
      100M100P100Q47054F
    • License MIT

    Simple and small copy-text-to-the-clipboard-utility with IE11 support

    Package Exports

    • clipboard-text

    Readme

    clipboard-text Build Status npm package

    Simple and small copy-text-to-the-clipboard-utility with IE11 support

    Installation

    npm install clipboard-text

    Usage

    import copy from 'clipboard-text'
    
    button.addEventListener('click', () => {
      copy('Hi there')
    })

    API

    copy(text: string, parentElement?: Element): boolean

    Copy text to the clipboard.

    If the event triggering the copy functions comes from an element with a focus trap, like a Modal, you will need to provide a parentElement. By default, parentElement is set to body.

    Returns a boolean of whether it succeeded to copy the text.

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

    License

    MIT