Copy Button
A copy button with direction-aware icon transitions.
Installation
bunx --bun shadcn@latest add "https://ratneshc.com/r/copy-button.json"
Usage
import { CopyButton } from "@/components/copy-button";<CopyButton text="This is a demo text" />API Reference
Extends Button with clipboard functionality.
| Prop | Type | Default | Description |
|---|---|---|---|
text | string | (() => string) | - | The text to copy, or a function that returns the text. |
idleIcon | ReactNode | - | Custom icon for idle state. |
doneIcon | ReactNode | - | Custom icon for done state. |
errorIcon | ReactNode | - | Custom icon for error state. |
onCopySuccess | (text: string) => void | - | Called with the copied text on successful copy. |
onCopyError | (error: Error) => void | - | Called with the error if the copy operation fails. |
See shadcn/ui documentation for more information.