ZUI

Search documentation

Find a page or a heading.

Copy Button

An icon button that copies its value to the clipboard, showing a check and carrying data-copied until its timeout resets it.

tsx

Installation

bash

Usage

tsx
tsx

Use it beside a value the reader might want to copy, such as a command or a code snippet's whole block.

API reference

CopyButton

Renders shadcn's Button and takes every prop it takes except value and children, plus:

It defaults variant to ghost and size to icon-xs. A caller's onClick runs before the copy, and calling event.preventDefault() in it skips the copy; a write the browser refuses, such as a denied clipboard permission, leaves the button idle. Its icon plays while the button is hovered or focused, and a caller's own pointer and focus handlers still run. It sets data-slot="copy-button" and data-copied while it shows its copied state. The check eases in, and reduced motion shows it at once.