Copy button
Copy a value with immediate confirmation.
npx shadcn@latest add @silicon-ui/copy-buttonInstallation
With the shadcn CLI
npx shadcn@latest add @silicon-ui/copy-buttonManually
Install the dependencies
npm install lucide-react motionCopy these files into your project
- components/silicon-ui/copy-button/copy-button.tsx
- components/silicon-ui/copy-button/copy-button.module.css
Shared with other components. Skip any you already have.
- components/silicon-ui/lib/use-copy-feedback.ts
Add the foundation, once per app, for the design and motion tokens
npx shadcn@latest add @silicon-ui/silicon-foundation
Usage
API reference
| Prop | Type | Default |
|---|---|---|
value* | string | — |
label | string | "Copy" |
className | string | — |
iconOnly | boolean | false |
variant`outline` (default) bordered; `plain` quiet, for inside a field; `soft` filled and borderless with a muted label, as Button's soft muted, for a bar (experimental). | "outline" | "plain" | "soft" | "outline" |
sizeHeight: `sm` 36px (default), or `xs` 24px with 12px words, for a toolbar beside xs controls (experimental). | "xs" | "sm" | "sm" |
shapeThe corners (experimental): `soft` (default) has the control radius; `pill` is fully round, a circle when `iconOnly`, as Button's `shape`. | "soft" | "pill" | "soft" |
disabled | boolean | — |
onCopied | () => void | — |
Dependencies
- npm
- lucide-reactmotion
- Registry
- silicon-motion-tokens