Oddmash UI
All components

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.

PropertyTypeDefault
textstringRequired
labelsClipboardLabelsEnglish labels
resetDelaynumber | null2500
announcebooleantrue
onCopied / onCopyErrorcallbackNone
<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>

Interactive documentation