Skip to content

@such12138/react-clipboard-lite โ€‹

Lightweight React components and hooks for clipboard operations with modern API support.

Features โ€‹

  • ๐Ÿš€ Modern Clipboard API with automatic fallbacks
  • ๐Ÿ“ฆ Tiny bundle size, zero dependencies
  • ๐ŸŽฏ TypeScript support with full type definitions
  • โ™ฟ Accessible and user-friendly
  • ๐Ÿงช Fully tested with Vitest + Testing Library
  • ๐Ÿ“– Interactive examples in Storybook

Quick Start โ€‹

bash
npm install @such12138/react-clipboard-lite
# or
pnpm add @such12138/react-clipboard-lite
# or
yarn add @such12138/react-clipboard-lite

Components โ€‹

CopyButton โ€‹

A button component that copies text to clipboard with visual feedback.

tsx
import { CopyButton } from "@such12138/react-clipboard-lite";

<CopyButton text="npm install @such12138/react-clipboard-lite">Copy Install Command</CopyButton>;

CopyOnClick โ€‹

A wrapper component that copies text when clicked.

tsx
import { CopyOnClick } from "@such12138/react-clipboard-lite";

<CopyOnClick text="Hello World">
  <code>Click to copy</code>
</CopyOnClick>;

useClipboard Hook โ€‹

A React hook for programmatic clipboard operations.

tsx
import { useClipboard } from "@such12138/react-clipboard-lite";

function MyComponent() {
  const { copy, isCopying, error } = useClipboard();

  return <button onClick={() => copy("Hello!")}>{isCopying ? "Copying..." : "Copy"}</button>;
}

Get started โ†’ Guide | API Reference