WlCopyButton
Appearance
Use copied and error to respond to the clipboard result. Give an icon-only button a specific name, such as “Copy order reference”.
ORD-2026-000184Full example
<div class="wl-inline" data-space="sm">
<code>{{ props.preview?.text ?? reference }}</code>
<WlCopyButton
:text="reference"
label="Copy"
aria-label="Copy order reference"
/>
</div>Content
ORD-2026-000184Full example
<div class="wl-inline" data-space="sm">
<code>{{ props.preview?.text ?? reference }}</code>
<WlCopyButton
:text="reference"
label="Copy"
aria-label="Copy order reference"
/>
</div>States
ORD-2026-000184Full example
<div class="wl-inline" data-space="sm">
<code>{{ props.preview?.text ?? reference }}</code>
<WlCopyButton
:text="reference"
label="Copy"
aria-label="Copy order reference"
/>
</div>Copy feedback
Edit the reference and copy it. The example shows the value received from copied or offers manual copying after an error.
Full example
<script setup lang="ts">
import { WlCopyButton, WlField, WlInput } from "legato-ui";
import { ref } from "vue";
const note = ref("REQ-0842");
const result = ref<{ ok: boolean; text: string }>();
</script>
<template>
<div class="wl-stack" data-space="sm">
<WlField v-slot="{ id }" label="Request reference">
<WlInput :id="id" v-model="note" />
</WlField>
<div>
<WlCopyButton
:text="note"
:disabled="!note.trim()"
@copied="result = { ok: true, text: $event }"
@error="result = { ok: false, text: $event }"
>
<template #default="{ copied }">
{{ copied ? "Copied" : "Copy" }}
</template>
</WlCopyButton>
</div>
<p v-if="result" class="wl-text-small">
{{ result.ok ? "Last copied" : "Clipboard unavailable. Copy manually" }}
<code>{{ result.text }}</code>
</p>
</div>
</template>Props
Types, accepted values and literal defaults come from the public manifest. Inherited settings name their source; “Not set” means no default is declared.
| Prop | Type / values | Default | Purpose |
|---|---|---|---|
text * | string | Required | Plain text sent to the browser clipboard after user activation. |
label | string | Not set | Visible button label and fallback accessible name. |
ariaLabel | string | Not set | Accessible action name, particularly for icon-only use. |
iconOnly | boolean | Not set | Show only the icon. |
variant | WlButtonVariant | "secondary" | Visual treatment of the button. |
size | WlSize | "md" | Size of the button. |
disabled | boolean | Not set | Prevent activation. |
pt | WlPt< | Not set | Attributes for the wrapper, native button and live status. |
Events
| Event | Payload | When emitted |
|---|---|---|
copied | [text: string] | The actual text successfully copied. |
error | [text: string] | The attempted text when copying fails or is unavailable. |
Slots
| Slot | Type / values | Content |
|---|---|---|
default | default?(props: { copied: boolean }): unknown; | Replace button text. Receives the current copy feedback state. |
Pass-through: pt
Sections WlCopyButton are listed below. Attributes merge in this order: createWlPt() WlConfig.ptpt instance. Class and style merge; the last supplied value takes priority for other attributes.
| Section | DOM | Purpose |
|---|---|---|
root | span.wl-copy-button | Main element of the component. |
button | button | Button used to activate the action. |
status | span[role=status] | Live status announcement. |
Sections refer to the component DOM. Dotted names identify a configuration group and its section; composite parts use their own pt groups. Global and local attributes merge, with class and style added together.
Keyboard and accessibility
- Use copied and error to respond to the clipboard result. Give an icon-only button a specific name, such as “Copy order reference”.
- The default button text briefly changes to Copied. The live region announces the result while focus stays on the button.
- When customizing the button slot, keep a clear name for the text being copied.
Keyboard and application responsibilities
Provide a meaningful accessible name and connect labels, hints and errors to the focusable element. Check the behavior with your own data and a screen reader.
WAI-ARIA Authoring PracticesIn your application, check keyboard controls, zoom and focus visibility. State labels and required information must be readable in every theme.