Skip to content
Calm motion: animations on this site only fade, with no movement

CopyButton ​

Copy text with a Copied state

A button that copies a text and says so. Use it beside a command, a token, an ID, or a link that people paste somewhere else.

Basic
npm install blessing-ui
  • value is the text. The component uses the Clipboard API and falls back to a hidden textarea where the API is missing.
  • The label changes to "Copied" for timeout ms (default 2000). A polite live region next to the button says "Copied to clipboard". The region is not part of the button name.
  • labels replaces the three English strings. The default slot replaces the button content and gets copied.
  • copy fires with the copied text. CodeBlock uses the same helper for its own copy button.

Usage ​

ts
import { BlessCopyButton } from "blessing-ui";

API ​

Props

NameTypeDefaultDescription
value*string—the text to copy
variant"solid" | "outline" | "ghost""outline"
size"md" | "sm" | "lg""md"
timeoutnumber2000ms the "Copied" state stays
labelsPartial<{ copy: string; copied: string; copiedLive: string; }>—

Events

NamePayloadDescription
copy[value: string]

Slots

NameScopeDescription
default{ copied: boolean; }

Released under the MIT License. Character names and artwork belong to their owners.