Officina UI
Components

CopyButton

Copies a string to the clipboard and shows a brief confirmation state.

CopyButton writes its value to the clipboard on click, then swaps its icon and label to a confirmation (copiedLabel) for about a second before reverting. Use it next to API keys, share links, code snippets, or IDs. If the clipboard write fails it raises a toast; it forwards Button props except onClick, which it owns.

Example

Preview
import { CopyButton } from '@officina/ui';

<CopyButton value="sk_live_8f2c…" copyLabel="Copy key" copiedLabel="Copied!" />;

API

PropTypeDefaultDescription
copiedLabelstringCopiedLabel shown briefly after a successful copy.
copyLabelstringCopyDefault button label.
isLoadingboolean—Show a loading spinner and disable the button while an action is in flight.
size"xs" | "sm" | "md" | "lg" | "icon" | "icon-sm" | null—
variant"primary" | "secondary" | "outline" | "ghost" | "soft" | "danger" | "success" | null—

On this page