Copy Button
Copies text to the clipboard and confirms with a blurred icon swap. Handles failures gracefully.
Inputs
$npx @plumsydev/plum-ui add button
Playground
Tweak the props, the preview and the code follow.
Props
1600
<CopyButton value="npx @plumsydev/plum-ui add copy-button" label="Copy" variant="outline" />
Installation
npx @plumsydev/plum-ui add copy-buttonAlso pulls in button automatically.
Usage
import { CopyButton } from "@/components/ui/copy-button"<CopyButton value="npm i plum" />Examples
With label
Pass label and the text swaps too.
API key
Copy with feedback through onCopied, next to a reveal toggle.
Production keyCreated Oct 12
pk_live_••••••••••••••••••API Reference
CopyButton
Accepts every Button prop except loading.
| Prop | Type | Default |
|---|---|---|
value*Text to copy, or a function evaluated on click. | string | (() => string) | — |
labelOptional visible label. Without it the button is icon-only. | string | — |
timeoutMilliseconds before resetting to idle. | number | 1600 |
onCopiedCalled after a successful copy. | (value: string) => void | — |
Notes
- The button exposes
data-state="idle" | "copied" | "error"for custom styling.