Loading...
Loading...
Loading...
Copy text to the clipboard with a temporary success flag that auto-resets.
Install
npx bouncekit@latest add usecopytoclipboardImport
import { useCopyToClipboard } from "@/hooks/use-copy-to-clipboard.ts"import { useCopyToClipboard } from "@/hooks/use-copy-to-clipboard"
const { copied, copy } = useCopyToClipboard()
<Button onClick={() => copy("text")}>
{copied ? "Copied!" : "Copy"}
</Button>API Reference
| Prop | Type | Required | Description |
|---|---|---|---|
resetDelay | number | — | How long copied stays true (ms). Default: 2000. |
Source
src/hooks/use-copy-to-clipboard.ts