- Label
- Icon label
- Field
- Form
- Frontmatter form
- Questionnaire
- Input
- Input group
- Input OTP
- Password input
- Password strength
- Code input
- Number field
- Tag input
- Textarea
- Checkbox
- Radio group
- Language toggle group
- Emoji appearance toggle group
- Emoji picker
- Avatar picker
- AI provider picker
- Select
- Native select
- Combobox
- Language combobox
- Slider
- Calendar
- Switch
- Alert
- Avatar
- Badge
- Card
- AI provider card
- Model info card
- Model list
- Empty
- Item
- Tree item
- File tree
- Icon media
- File type icon
- Font preview
- Image preview
- Kbd
- Table
- Data table
- Data table column header
- Chart
- Code Block
- Code card
- Markdown view
- Attachment
- Bubble
- Marker
- Message
- Chat message
- Chat suggestion item
- Message scroller
- Trace
- Progress
- Spinner
- Sonner
- Toast
- Unsaved changes toolbar
- Unsaved indicator
- Status indicator
- Permission card
- Separator
- Skeleton
- Animated grid pattern
- Meteors
An icon button that copies its value to the clipboard, showing a check until its timeout resets it.
Installation#
pnpm dlx shadcn@latest add @zui/copy-buttonThe CLI writes components/feedback/copy-button.tsx, installs Button,
Icon and Text, and adds
expo-clipboard and lucide-react-native.
Usage#
import { CopyButton } from '@/components/feedback/copy-button';<CopyButton value={command} />Use it beside a value the reader might want to copy, such as a command or a code snippet's whole block.
API reference#
CopyButton#
Takes every prop of Button except children, plus:
| Prop | Type | Default |
|---|---|---|
value | string | required |
label | string | 'Copy' |
copiedLabel | string | 'Copied' |
timeout | number | 2000 |
onCopied | (value: string) => void | - |
It defaults variant to ghost and size to icon-xs. After a successful copy it shows a check and takes
copiedLabel as its name for timeout ms, then resets. A screen reader hears copiedLabel once the copy has
succeeded: iOS through an announcement, Android and the web through a polite live region. A caller's onPress
runs before the copy, and calling event.preventDefault() in it skips the copy; a write the clipboard refuses
leaves the button idle. Pass label and copiedLabel translated.
Differences from the web#
onPressstands in for the web'sonClick.- The icon is static and the check shows at once; the web's icon plays while the button is hovered or focused, which a phone has not, and its check eases in.
- The web's
data-slotanddata-copiedattributes are not set; a View takes no data attributes.