Skip to content

Components

Copy Button

Icon button that copies a value and confirms with a checkmark.

Copies a value to the clipboard. The icon turns into a checkmark for two seconds, and “Copied” is announced to screen readers.

Terminal window
npx shadcn@latest add @0xui/copy-button
import { CopyButton } from "@/components/copy-button";
<CopyButton value={address} label="Copy address" />;

Always pass a specific label. It is the button’s only accessible name.

Accepts every shadcn Button prop, including variant and size.

<CopyButton value={hash} label="Copy transaction hash" variant="outline" size="icon" />
State What the user sees
Idle Copy icon.
Copied Checkmark for timeout ms, “Copied” announced. data-copied is set on the button.
Clipboard blocked Nothing changes and onCopy is not called.

Also accepts all shadcn Button props except onClick and children.

Prop Type Default Description
value string — Text to copy.
label string "Copy" Accessible label and tooltip.
timeout number 2000 How long the copied state lasts, in ms.
onCopy (value: string) => void — Called after a successful copy.
copyIcon ComponentType | false CopyIcon Custom icon, or false to hide it.
copiedIcon ComponentType | false CheckIcon Custom icon, or false to hide it.