Clipboard
Used by the docs copy buttons and handy for snippets.
Copies text to the clipboard and tracks copied/error state.
Hook
import { useClipboard } from "@swirski/ui";Used by the docs copy buttons and handy for snippets.
const clipboard = useClipboard();
<Button onClick={() => clipboard.copy("pnpm add @swirski/ui")}>
{clipboard.copied ? "Copied" : "Copy"}
</Button>| Prop | Type | Default | Notes |
|---|---|---|---|
options.timeout | number | 1600 | Copied-state reset delay in milliseconds. |
| Value | Type | Notes |
|---|---|---|
copied | boolean | True immediately after a successful copy. |
copy | (value: string) => Promise<void> | Copies text to the clipboard. |
error | Error | null | Last copy error. |
reset | () => void | Clears copied and error state. |