CopyButton
v1.0.7Updated 27 Aug 2026Button that copies a value to the clipboard — a plain string or a sync/async producer resolved at click time. Writes via navigator.clipboard with a hidden-textarea/execCommand fallback, flips to a check icon for a config
Preview
Live · 12 stories▸Why this is recommendedcopyclipboardbuttonsnippet+3
The default, out-of-the-box CopyButton.
- ✓Copying invoice numbers, tax IDs, account numbers
- ✓Copy-link / share-URL actions (minted async)
- ✓Code or API-key snippets in settings pages
- String or async () => string value (resolved on click)
- navigator.clipboard with textarea/execCommand fallback
- Copied state with check icon, configurable timeout
- Copy / Copied tooltip (hideable) + sr-only live region
- Controlled or uncontrolled copied state
- onCopied / onError / onCopiedChange callbacks
- Full Button tone x emphasis x size inheritance
- Headless useClipboard hook { copy, copied, error, reset }
- Reduced-motion safe icon crossfade
- ✕Generic actions without clipboard semantics (use Button)
- ✕Copying rich HTML content (plain text only)
Install
Ask your agent, or call the MCP tool directly. The resolved bundle is written into your project.
Usage
Tick variants in the left menu — each adds a tab with that variant’s real story source, the same code the preview above renders.
Props
valueText to copy, or a sync/async producer of it
yestimeoutHow long the copied state persists in ms (default 2000)
—copiedControlled copied state
—onCopiedChangeMirrors internal copied-state changes
—onCopiedCalled with the resolved text on success
—onErrorCalled when resolving or writing fails
—copyLabelIdle tooltip / accessible label (default "Copy")
—copiedLabelCopied tooltip / announced label (default "Copied")
—showTooltipHide the tooltip; live region remains (default true)
—toneSemantic tone (default neutral)
—emphasisVisual loudness (default ghost)
—sizeButton size
—Every tonal component shares the same tone × emphasis API, so the pair looks identical across Button, Badge, Alert and more.