Clipboard Button
Copy real text and report the result.
Usage
Pass the exact text and localized labels to ClipboardButton. The copy action runs only from activation and keeps the native button focused. Use announce={false} with an external toast when the same result is announced there. Set data-om-motion="fold" on the button or an ancestor for the built-in confirmation icon when using the default label.
Accessibility
A pre-existing live region announces completed copies and failures. Preserve keyboard activation, provide a manual selection path, and use a text or icon state that does not rely on color alone.
| Property | Type | Default |
|---|---|---|
| text | string | Required |
| labels | ClipboardLabels | English labels |
| resetDelay | number | null | 2500 |
| announce | boolean | true |
| onCopied / onCopyError | callback | None |
<div>
<pre tabIndex={0} role="region" aria-label="Clipboard example code"><code>pnpm add @oddmash/ui</code></pre>
<ClipboardButton
text="pnpm add @oddmash/ui"
labels={{ idle: 'Copy code', pending: 'Copying code', copied: 'Copied', error: 'Select the code to copy' }}
/>
</div>