Xzero UI
Pro library

Copy button

Copy a value with immediate confirmation.

$ pnpm dlx shadcn@4.23.0 add @xzero-ui/copy-button
Live · keyboard ready

When to use

When not to use

Installation

Register both Xzero UI namespaces in your project's components.json:

{
  "registries": {
    "@xzero-ui": "https://mcp.xzero.co.uk/r/{name}.json",
    "@xzero-ui-pro": "https://mcp.xzero.co.uk/r/pro/{name}.json"
  }
}
npx shadcn@4.23.0 add @xzero-ui/copy-button

Install xzero-foundation once, and import @/components/xzero/foundation.css in your app root. No Xzero token is used by this snapshot. For sample portraits, photos, fonts, or logos, download https://mcp.xzero.co.uk/install-assets.mjs and run node xzero-install-assets.mjs <receiving-project>.

Usage

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

export function ApiKeyRow({ apiKey }: { apiKey: string }) {
  return (
    <div className="row">
      <code>{apiKey}</code>
      <CopyButton value={apiKey} label="Copy key" iconOnly />
    </div>
  );
}

API reference

CopyButton

Copies a string to the clipboard and crossfades its icon and label to Copied or Failed.

PropTypeDefaultDescription
value (required)string–The text to copy.
labelstring"Copy"Idle label and accessible name.
iconOnlybooleanfalseHides the text and shows only the icon.
variant"outline" | "plain""outline"Bordered or borderless.
disabledboolean–Disables the button.
onCopied() => void–Called after a successful copy.
classNamestring–Extra class on the button.

Keyboard interactions

KeysAction
Enter / SpaceCopies the value.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Also in buttons

Guidance for AI tools

Copy button: Copy a value with immediate confirmation. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://ui.xzero.co.uk/llms.txt

Browse all components