WlCopyButton

Copies text with a status announcement and leaves focus on the action.
Components / Actions v1.4.0

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-000184
Full 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-000184
Full 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-000184
Full 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>