JSPM

qwik-clipboard

1.0.0
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 1
    • Score
      100M100P100Q9557F
    • License MIT

    Reactive clipboard hook for Qwik framework

    Package Exports

      This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (qwik-clipboard) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

      Readme

      Qwik Clipboard Utility

      A reactive clipboard hook for Qwik framework.

      Installation

      npm install qwik-clipboard

      Usage

      import { component$ } from '@builder.io/qwik';
      import { useClipboard } from 'qwik-clipboard';
      
      export const CopyButton = component$(() => {
        const { copied, copy } = useClipboard('Hello Qwik!');
      
        return (
          <button onClick$={() => copy()}>
            {copied.value ? 'Copied!' : 'Copy to Clipboard'}
          </button>
        );
      });

      API

      useClipboard(initialValue?: string)
      
      initialValue: Optional initial text to copy.
      
      Returns:
      
      copied (signal): true if last copy succeeded, else false.
      
      copy(text?: string): Function to copy text to clipboard.