Copy Button

Copies text to the clipboard and confirms with a blurred icon swap. Handles failures gracefully.

Inputs
$npx @plumsydev/plum-ui add button

Playground

Tweak the props, the preview and the code follow.

Props
1600
<CopyButton value="npx @plumsydev/plum-ui add copy-button" label="Copy" variant="outline" />

Installation

npx @plumsydev/plum-ui add copy-button

Also pulls in button automatically.

Usage

import { CopyButton } from "@/components/ui/copy-button"
<CopyButton value="npm i plum" />

Examples

With label

Pass label and the text swaps too.

API key

Copy with feedback through onCopied, next to a reveal toggle.

Production keyCreated Oct 12
pk_live_••••••••••••••••••

API Reference

CopyButton

Accepts every Button prop except loading.

PropTypeDefault
value*

Text to copy, or a function evaluated on click.

string | (() => string)—
label

Optional visible label. Without it the button is icon-only.

string—
timeout

Milliseconds before resetting to idle.

number1600
onCopied

Called after a successful copy.

(value: string) => void—

Notes

  • The button exposes data-state="idle" | "copied" | "error" for custom styling.