Copy button

Copy button is a neobrutalist React component from Cruise UI. Copies a value (account number, code, key) and shows "Copied" or a toast; if the browser blocks it, it shows the text to copy by hand. Install it with npx shadcn@latest add @cruiseui/cruise-copy-button.

Install

Terminal

npx shadcn@latest add @cruiseui/cruise-copy-button

First time? Installation shows the one-off components.json setup (the @cruiseui registry) and how to turn the theme on.

Example

Corners

0123456789

When to use it

When to use

Account numbers, referral codes, API keys, snippets.

When not to

Copying long documents (offer a download instead).

Props

CruiseCopyButton

PropTypeDefaultDescription
valuestring—The text to copy.
label?string"Copy"Button text, or its accessible name when iconOnly (e.g. "Copy account number").
copiedLabel?string"Copied"—
iconOnly?booleanfalseA 44px square icon button.
toast?string | booleanfalseAlso show a toast (needs a <CruiseToaster /> mounted).
variant?CruiseButtonVariant"secondary"—
onCopied?(() => void)——
className?string——

Accessibility

  • Icon-only buttons have an aria-label, e.g. "Copy account number".
  • "Copied" (or the failure) is announced in an aria-live region.
  • Failure is explained in words, with the value shown to select by hand.