Copy button
A React component in Beamline's Actions category, in the free sample.
Copies a value and confirms in place: the icon becomes a check and the label says Copied; a refused copy says so instead of pretending.
Use it for
- Copying a key, an id, a URL or a code snippet with visible confirmation.
Not for
- Copying whole documents or files (offer a download).
Anatomy
- Button
- icon (copy → check / x)
- label
- live status for screen readers
Variants
- variant: secondary (default), outline, ghost, plain (alias of ghost), primary
- size: sm, md, lg
States
- idle
- copied (1.6 s)
- failed (visible message; the insecure-context fallback releases its temporary field and restores focus)
- disabled
Keyboard
- Enter / Space copies
Motion
Icon feedback uses --pui-duration-feedback (existing 160ms default); reduced/none swaps instantly. Copy result timeout is reading time and does not scale with animation speed. Placed as a waiting action (className="reveal" inside a .reveal-host) it shows on hover or focus, and stays while its result shows (data-shown), so a confirmation never vanishes under a leaving pointer.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | — | The text that lands on the clipboard. |
label | string | "Copy" | What is copied, e.g. "Copy API key"; the accessible name when icon-only. Default "Copy". |
copiedLabel | string | — | The confirmation in your words, shown in place of the label and said to a screen reader: "Link copied". Default "Copied" (heard as "Copied to clipboard"). |
iconOnly | boolean | — | |
variant | ButtonVariant | "plain" | "secondary" | Any Button variant; "plain" is kept as an alias of ghost. Default secondary. |
size | ButtonSize | "sm" | |
onCopied | () => void | — | Runs after a successful copy. |
timeout | number | 1600 | How long "Copied" stays, ms. Default 1600. |
classNames | CopyButtonClassNames | — | Classes for the named visual parts; no overrides by default. |
style / ref | CSSProperties / native Ref | — | style: Inline styles on the documented visual root; no overrides by default. ref: Receives the documented native target or imperative handle; omitted by default. |
labels | Partial<{ label: Message; copied: Message; error: Message; copiedDescription: Message; … | — | Per-instance copy; overrides UIRoot messages. |
disabled | boolean | — | |
className | string | — | Classes on the documented visual root; no override by default. |
style | CSSProperties | — | Inline styles on the documented visual root; no overrides by default. |
ref | Ref<HTMLButtonElement> | — | Receives the documented native target or imperative handle; omitted by default. |
Built from
Used in
- Security
- AI agent workspace
- API keys & webhooks
- Artifact workbench
- Audit log
- Automation runs
- Benefit changes
- Services and hours
- Changelog feed
- Contact profile
- Conversation history
- Domain verification
- Email automation
- Empty states
- Equipment register
- File manager
- Gift batches
- Gift desk
- Issued ticket
- Lease setup
- Payroll cycles
- Pipeline record
- Prototype review
- Query library
- Queue settings
- Reservation desk
- Review share
- Room readiness
- Run of show
- Session replay
- Settings
- Social media scheduler
- Special orders
- Stay folio
- AI support chat
- System pages
- Workflow builder
Dependencies
lucide-react, motion
Import
import { CopyButton } from "@beamline/copy-button";
Get it
Copy button is part of Beamline UI. Install the parts you need in your React app as compiled packages or editable source. Copy button is included in the free MIT sample. Get Beamline · Connect your agent
More in Actions
- Consequence preview: A risky action that shows what it will do before it runs: one headline sentence, what blocks it and what it also reaches as bands, then the rest as cards…
- Theme switch: The light/dark control: the page changes in one of four transitions starting from the button (reveal, eclipse, split, rise), and the icon turns between…
- Confirm morph: A destructive action that asks in place: the button morphs into its question, then into working, then into the result with Undo or Retry, without a dialog.
- Swipe actions: Row actions behind a swipe on touch screens and a two-finger swipe on a trackpad, and at the row's end for pointer and keyboard (a ⋯ menu in a narrow…
- Hold to confirm: Confirms a costly action by holding instead of clicking: a fill sweeps across while held and drains if let go early; pointer, touch, Space and Enter all…
- Split button: One obvious action joined to a menu of close alternatives; both halves are real buttons and the menu uses the shared menu rows.
- Button: The action control: five weights and a brand fill, a buy/sell tone, sm/md/lg and a 44 px touch size, icon-only, a loading state that keeps its size and…