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-uivue
<template>
<div style="display: flex; gap: 1rem; align-items: center; flex-wrap: wrap">
<code>npm install blessing-ui</code>
<BlessCopyButton value="npm install blessing-ui" />
<BlessCopyButton value="npm install blessing-ui" variant="ghost" size="sm" />
</div>
</template>
<script setup lang="ts">
import { BlessCopyButton } from "blessing-ui";
</script>valueis 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
timeoutms (default 2000). A polite live region next to the button says "Copied to clipboard". The region is not part of the button name. labelsreplaces the three English strings. The default slot replaces the button content and getscopied.copyfires with the copied text. CodeBlock uses the same helper for its own copy button.
Usage
ts
import { BlessCopyButton } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
value* | string | — | the text to copy |
variant | "solid" | "outline" | "ghost" | "outline" | |
size | "md" | "sm" | "lg" | "md" | |
timeout | number | 2000 | ms the "Copied" state stays |
labels | Partial<{ copy: string; copied: string; copiedLive: string; }> | — |
Events
| Name | Payload | Description |
|---|---|---|
copy | [value: string] |
Slots
| Name | Scope | Description |
|---|---|---|
default | { copied: boolean; } |