CopyButton
Actions

CopyButton

Copies text to the clipboard and confirms in place: the icon swaps to a check instead of showing a toast.

Props

CopyButton extends ButtonHTMLAttributes<HTMLButtonElement> except children, value, and onCopy. The copy value can be a string or a function evaluated on click.

CopyButtonProps props
PropTypeDefaultDescription
valuestring | (() => string)—The text to copy. A function is called at click time.
labelReactNode—Text beside the icon. Omit for icon-only.
copiedLabelReactNode"Copied"Replaces label while in the copied state.
timeoutnumber1400How long the confirmation state lasts (ms).
size"sm" | "md""md"Button size.
variant"ghost" | "outline""ghost"Visual treatment.
onCopy(ok: boolean) => void—Called after the copy attempt.

Examples

With label

CopyButton with label

Icon-only

Icon-only CopyButton

Custom timeout

CopyButton timeout
ImportTSX
import { CopyButton } from "@solarius/onset";

<CopyButton value="sk_live_abc123" label="Copy API key" />
<CopyButton value={() => getSecret()} label="Copy" />