Captain UI

Copy button

Press it and the copy mark lifts away while a check draws itself in, then it settles back. Screen readers hear Copied.

npx shadcn@latest add https://captain-ui.vercel.app/r/copy-button.json
$ npx shadcn@latest add https://captain-ui.vercel.app/r/copy-button.json

Fix checkout race in the webhook handler

Commit 4f1c9e2 on fix/checkout-race

Usage

import { CopyButton } from "@/components/ui/copy-button"

<CopyButton value={command} aria-label="Copy install command" />

Props

PropTypeDefaultWhat it does
valuestring | () => string | Promise<string>What to copy. A function runs at click time, so it can read the latest text.
labelstringOptional visible label. The button keeps its width when it changes to Copied.
copiedLabelstring"Copied"Shown and announced after a copy.
aria-labelstring"Copy"Name for the icon-only button. Say what it copies.
onCopy(text: string) => voidCalled after a successful copy.
timeoutnumber1600How long the check stays, in ms.
size"sm" | "md""md"32 or 36px. The hit area is always 44px.

Keyboard

Enter
Copy
Space
Copy

Accessibility

  • A real button. Icon-only buttons need an aria-label that says what is copied.
  • A polite status region announces Copied, or Copy failed when the clipboard refuses.
  • Reduced motion swaps the morph and the stroke draw for a plain crossfade.