@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-liteComponents โ
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