---
agent:
  instructions: "Search goop.so for Goop's components, templates, design skill, docs, pricing and terms. Ask in keywords or a plain question, such as \"date picker props\" or \"is the design skill free\"; the answer is the matching page sections in Markdown, each with its address."
  endpoint: "https://goop.so/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Copy button

A button that copies a value such as a link, a key or a command to the clipboard and says it was copied in place, for React and Tailwind CSS. Part of Goop Pro.

Pro. Its export: `CopyButton`.

## When to use

- A button that copies a value such as a link, a key or a command to the clipboard and says it was copied in place.
- Also called: copy to clipboard.

## Installation

Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Copy button on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing. As a Pro part, its command comes from Goop's server once you sign in, with a one-time link that lasts ten minutes.

```sh
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-copy-button.json --yes
```

```text
Add the Goop Copy button to this project. The install steps are at https://goop.so/docs/install.md
```

## Usage

```tsx
import { CopyButton } from '@/components/ui/goop/copy-button';
import { TextInput } from '@/components/ui/goop/text-input';

function ApiKeyRow() {
  const key = 'key_live_7Hq2xV9mK4tR8wN3cL6p';
  return (
    <div className="flex flex-col items-start gap-3">
      <div className="flex w-full items-center gap-2">
        <TextInput aria-label="API key" readOnly value={key} className="min-w-0 flex-1 text-ellipsis" />
        <CopyButton value={key} label="Copy key" variant="outline" size="lg" />
      </div>
      <CopyButton value="https://example.com/invite/7f3a9c" label="Copy invite link" iconOnly size="md" />
    </div>
  );
}
```

- Also known as: CopyToClipboard, ClipboardButton, Clipboard.
- Put a CopyButton at the end of any value a person will paste elsewhere — a key, a link, an id — and let it confirm in place; a value shown in the theme's mono is a `CodeBlock`, which has its own copy button. Never a Toast for the confirmation.
- height, padding: add no class for these.

## API reference

### Options

- `value: string` — What is copied: the exact text put on the clipboard.
- `label?: string = 'Copy'` — The words at rest; with `iconOnly`, the button's name and its tooltip — say what is copied ("Copy API key").
- `copiedLabel?: string = 'Copied'` — The words once the value is on the clipboard.
- `failedLabel?: string = 'Couldn’t copy'` — The words when the copy failed.
- `iconOnly?: boolean = false` — The glyph alone, on the theme's quiet IconButton; `label` names it and shows in its tooltip.
- `variant?: 'ghost' | 'outline' = 'ghost'` — `ghost` (no fill at rest) or `outline` (the card fill: inside its 1 px grey edge at lg, the raised chip's soft drop at sm and md).
- `size?: 'sm' | 'md' | 'lg' = 'sm'` — `sm` and `md` 28 px with words (24 and 28 px for the glyph alone), `lg` 40 px (beside a `TextInput`).
- `onCopy?: (value: string) => void` — Called with `value` once it is on the clipboard.
- `onClick?: (event: MouseEvent) => void`
- `disabled?: boolean`

## Keyboard

- Enter: copy the value; the focus stays on the button
- Space: copy the value; the focus stays on the button

## Accessibility

- The part itself answers the keys above.
- hover, active, focus-visible: the browser's own (:hover, :active, :focus-visible): write nothing
- disabled: the prop disabled

## Notes for AI

Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.

## Related

- [Text input](/themes/meadow/components/text-input): A single-line field for free words, such as a task's title, a name or an email.
- [Menu button](/themes/meadow/components/menu-button): The button a menu opens from, shown as words, a workspace's tile or an icon.
- [Color mode toggle](/themes/meadow/components/color-mode-toggle): The app's light and dark mode switch.
- [Link](/themes/meadow/components/link): A text link to another page or place.
