# Copy Button

> A copy button whose two sheets slide together into a check while the label rolls to Copied.

## Spec sheet

| | |
| --- | --- |
| Access | Free: no account, free for commercial use |
| Shelf | Components › Buttons |
| Live preview | https://uibrik.com/components/copy-button |
| Writes | 1 file into `components/uibrik/copy-button/` |
| Packages | `motion`, `react-use-measure` (the CLI installs them) |
| Needs | React 19, Tailwind CSS v4, a project set up with `npx shadcn@latest init` |
| Theme | Reads the shadcn tokens and follows class-based dark mode ([theming](https://uibrik.com/docs/theming.md)) |
| Updated | Nov 9, 2026 |

## Add it

```bash
npx shadcn@latest add https://uibrik.com/r/copy-button.json
```

With the `@uibrik` namespace in `components.json` ([setup](https://uibrik.com/docs/installation.md)): `npx shadcn@latest add @uibrik/copy-button`.

Can't run commands? https://uibrik.com/components/copy-button/prompt.txt has every file verbatim, with the setup steps, ready for an assistant to write.

## Render it

Renders as is; every value shown is the default, so delete any line you don't need.

```tsx
import { CopyButton } from "@/components/uibrik/copy-button/copy-button";

<CopyButton
  text="npm install motion"
  label="Copy"
  copiedLabel="Copied"
  display="label"
  variant="soft"
  size="md"
  tintSuccess={false}
  resetAfter={1.5}
  radius={12}
  onCopy={(text) => {}}
/>
```

## Tune it

The same props as the Customize panel on https://uibrik.com/components/copy-button.

| Prop | Type | Default | What it does |
| --- | --- | --- | --- |
| `text` | `string` | `"npm install motion"` | Text written to the clipboard. |
| `label` | `string` | `"Copy"` | Button text. |
| `copiedLabel` | `string` | `"Copied"` | Shown once the text is copied. |
| `display` | `"label" \| "icon"` | `"label"` | Icon and label, or the icon alone (the label stays as its accessible name). |
| `variant` | `"soft" \| "ghost" \| "outline"` | `"soft"` | Filled, transparent until hovered, or outlined. |
| `size` | `"sm" \| "md" \| "lg"` | `"md"` | Height, padding and text size. |
| `tintSuccess` | `boolean` | `false` | Colour the copied state instead of keeping it neutral. |
| `successColor` | `string` | `"#16a34a"` | Colour of the copied state when tinted. |
| `resetAfter` | `number` | `1.5` | How long Copied shows before reverting. |
| `radius` | `number` | `12` | Corner radius. |

## Wire it

The props the Customize panel doesn't show: ranges, data, content and callbacks.

| Prop | Type | Default | What it does |
| --- | --- | --- | --- |
| `onCopy` | `(text: string) => void` |  | Called after a successful copy. |
| `className` | `string` |  | Classes for the button. |

## Where it fits

- **Code snippets**: Sheets sliding into a check confirm the copy without a toast covering the code. Pairs with [Code Block](https://uibrik.com/components/code-block.md).
- **API keys and invite links**: A label that rolls to Copied gives a clear success state for one-off secrets and links. Pairs with [Settings Page](https://uibrik.com/components/settings-page.md) (Pro).
- **Coupon and referral codes**: A clear confirmation helps shoppers trust the code is on their clipboard before checkout.

## Same shelf: Buttons

- [Expand Button](https://uibrik.com/components/expand-button.md): An icon-only button that springs open to reveal its label on hover or keyboard focus.
- [Hold to Confirm](https://uibrik.com/components/hold-to-confirm.md): A destructive-action button that has to be held down; a fill grows across it and drains back if released early.
- [Inline Confirm](https://uibrik.com/components/inline-confirm.md): A destructive button that splits into Cancel and Confirm in its own footprint, so nothing around it moves.
- [Mesh Button](https://uibrik.com/components/mesh-button.md) (Pro): A button painted with a softly blended mesh gradient under rolling silk waves that catch a satin sheen; the pointer presses into the silk and a click ripples it.
- [Prism Button](https://uibrik.com/components/prism-button.md) (Pro): A graphite button with a border of polished metal that splits light like a prism; the glint travels round the border and turns to follow the pointer.
- [Share Menu](https://uibrik.com/components/share-menu.md): A share button that flips open into a pill of options, resizing to fit.

## Ground rules

- Only the props above exist. To change anything else, edit the installed file.
- Keep the files in `components/uibrik/copy-button/` so the import paths keep resolving.
- The playbook for working with the whole library: https://uibrik.com/llms.txt
