Skip to content

Actions

CopyButton

Copies a text to the clipboard and confirms it visibly and for screen readers.

  • Experimental
  • Keyboard tested
  • Screen reader not tested yet

Updated 2026-11-12

Playground

Change the props. The controls come from the documented props.
tsx
<CopyButton text="text-secondary" label="Copy utility" />

Usage

When to use

Use a copy button next to text people will paste somewhere else: code, a token name, a link, an ID.

When not to use

  • For text people only read.
  • As a general action button: it does exactly one thing.

How it works

A click copies the text to the clipboard. The label changes to “Copied” for a moment and a live region announces it, so the confirmation is visible and audible.

Content guidelines

Name what is copied when there is more than one button on the page: “Copy code”, “Copy class”. A lone “Copy” is enough only when nothing else could be meant.

Do and don’t

Do
  • Name what is copied when there are several buttons, e.g. “Copy code”.
Don’t
  • Don't copy without a visible confirmation.

Anatomy

The parts of the component and what each one does, as in the playground above.
  1. iconCopy icon, a check after copying.
  2. labelChanges to copiedLabel for two seconds.

Examples

Type-checked, and the same code goes into the AI manifest. Import: import { CopyButton } from "@/ds";

Copy a token

Props

Checked against the component's TypeScript type on every build.
CopyButton props
NameTypeDefaultDescription
text (required)string–Text that goes to the clipboard.
labelstring"Copy"Label before copying.
copiedLabelstring"Copied"Label and announcement after copying.
variant"primary" | "accent" | "secondary" | "ghost""ghost"Button variant.
size"sm" | "md""sm"Button size.

Tokens used

Derived from the utility classes in the component's source. Copy a class with one click.
Tokens used by CopyButton
TokenTierValueUtility
spacing.4semantic16px
text.secondarysemantic#555555

Accessibility

What is checked automatically on every build, and what a person has tested. Nothing is marked as tested unless it was.
Testing status by check
CheckHowStatus
axe-core rulesAutomated on every npm run check, at desktop and mobile widthRuns on every build
KeyboardAutomated Playwright test (scripts/keyboard.mjs)Tested
Screen readerManualNot tested yet

Keyboard

CopyButton keyboard interactions
KeyAction
Enter / SpaceCopies the text.

Semantics and focus

  • The result is announced through a role="status" live region.