Copy button
A button beside a value that puts it on the clipboard. It confirms for two seconds, and the confirmation is in the accessible name as well as the icon, so it is not visual only.
Reach for it
Copying a value the user cannot see in full, or one beside its own label.
Not for
Copying visible text a reader would rather click. Use Copy underline.
Beside a value
Both labels are required. The name flips with the state, so the button always says what pressing it will do, and a screen reader hears the confirmation rather than only seeing it.
INV-1042
Nothing to copy yet
API reference
CopyButton
| Prop | Type | Default | Description |
|---|---|---|---|
| value* | string | - | The text written to the clipboard. Explicit, never read off the children. |
| copyLabel* | string | - | Names the button at rest, e.g. "Copy invoice reference". |
| copiedLabel* | string | - | Names it during the confirmation, e.g. "Copied". |
| data-testid | string | - | Names the element for a test. Never rendered, never announced. |
| isDisabled | boolean | - | |
| onCopyError | (error: unknown) => void | - | A clipboard write can fail: an http origin has no clipboard API at all, and a browser can refuse the permission. The package has no copy to announce that with, so the caller is told and decides. |