Button
CopyButton
A button that copies text to the clipboard, answers with a tick for a moment, and tells a screen reader it worked.
WAI-ARIA tested
Import
main.ts
import { CopyButton } from '@vitral/vue';Basic
With no `label` it shows only its icon, named “Copy”. `value` may be a function, and it may wait.
pnpm add @vitral/vueBeside a field
API
Read from packages/vue/src/components/CopyButton/types.ts, so it says what the component actually accepts.
Props
| Name | Type | Description |
|---|---|---|
| value | string | (() => string | Promise<string>) | What is copied, or a function returning it (and it may wait). |
| label | string | Without one the button shows only its icon, named "Copy". |
| copiedLabel | string | Shown in place of `label` for a moment once copied. |
| timeout | number | How long the tick stays, in milliseconds. Defaults to 2000. |
| severity | Severity | Defaults to `'secondary'`. |
| variant | 'filled' | 'outlined' | 'text' | Defaults to `'text'`. |
| size | Size | — |
| rounded | boolean | — |
| disabled | boolean | — |
Plus pt, dt and unstyled from BaseProps, see pass-through and unstyled mode.
Emits
| Event | Payload | Description |
|---|---|---|
| copy | value: string | — |
| error | error: unknown | — |