Copy Button

Copy text and watch the icon blur into a check as Copy becomes Copied.

Preview

"use client";

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

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

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @beui/copy-button

API Reference

value
string | (() => string)

Text to copy, or a function that returns it at click time.

Default—
onCopy?
((value: string) => void)

Called with the copied text after it reaches the clipboard.

Default—
timeout?
number

How long the copied state holds, in milliseconds.

Default1600
showLabel?
boolean

Show "Copy" / "Copied" next to the icon.

Defaultfalse
labels?
Partial<{ copy: string; copied: string; }>

Override any built-in string, e.g. for translation.

Default—
sound?
boolean

Play two quick ticks once the text is copied. Off by default; a `SoundProvider` can mute it app-wide.

Defaultfalse
className?
string

Classes merged onto the root element.

Default—

Updated