---
title: "Copy Button"
description: "Copies text and confirms it: the pill tints, the icon blurs into a check that draws its stroke, and Copy morphs letter by letter into Copied."
category: "Micro Interactions"
publishedAt: "2026-11-16"
updatedAt: "2026-11-25"
documentation: "https://beui.dev/micro-interactions/copy-button"
markdown: "https://beui.dev/micro-interactions/copy-button.md"
license: "MIT"
---

# Copy Button

> Copies text and confirms it: the pill tints, the icon blurs into a check that draws its stroke, and Copy morphs letter by letter into Copied.

## Install

```bash
npx shadcn@latest add @beui/copy-button
```

## Dependencies

- `clsx`
- `lucide-react`
- `motion`
- `react`
- `tailwind-merge`

## Usage

```tsx
"use client";

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

export function CopyButtonPreview() {
  return <CopyButton sound value="npx shadcn@latest add @beui/copy-button" showLabel />;
}
```

## API Reference

### CopyButton

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `value` | `string \| (() => string)` | — | Yes | Text to copy, or a function that returns it at click time. |
| `onCopy` | `((value: string) => void)` | — | No | Called with the copied text after it reaches the clipboard. |
| `timeout` | `number` | `1600` | No | How long the copied state holds, in milliseconds. |
| `showLabel` | `boolean` | `false` | No | Show "Copy" / "Copied" next to the icon. |
| `labels` | `Partial<{ copy: string; copied: string; }>` | — | No | Override any built-in string, e.g. for translation. |
| `sound` | `boolean` | `false` | No | Play two quick ticks once the text is copied. Off by default; a `SoundProvider` can mute it app-wide. |
| `className` | `string` | — | No | Classes merged onto the root element. |

## About Copy Button

Copy Button is a React copy to clipboard button built with Framer Motion. A click writes the value to the clipboard and confirms it: the button tints with the primary colour, the copy icon blurs away as a check scales in and draws its stroke, and with a label the word morphs with Text Morph: "Cop" stays while the rest of Copied springs in letter by letter and the pill resizes to fit. It settles back after a timeout.

### When to use it

- A code block, install command or API key needs a one-click copy.
- A share sheet copies a link.
- A contact card copies an email address.

### Accessibility

It renders a real button. Icon only, it is named Copy; with showLabel the visible text names it. A polite live region announces Copied after each copy. With reduced motion the icons crossfade without scaling or blur.

### FAQ

**Can the copied text be computed at click time?**

Yes. Pass a function as value and it runs on each click, so the button always copies the latest text.

**What happens if the clipboard is blocked?**

The button stays in its copy state and onCopy does not fire, so you never show a false Copied.

## Source

- Registry detail: https://beui.dev/r/copy-button
- Raw source: https://beui.dev/r/copy-button/raw
- GitHub: https://github.com/starc007/ui-components
