WlTag
Appearance
Full example
<script setup lang="ts">
import { WlButton, WlTag } from "legato-ui";
import { ref } from "vue";
const visible = ref(true);
</script>
<template>
<div class="wl-stack" data-space="md">
<WlTag
v-if="visible"
removable
color="blue"
tone="info"
icon="check"
size="sm"
remove-label="Remove Design tag"
@remove="visible = false"
>{{ "Design" }}</WlTag>
<WlButton v-else size="sm" @click="visible = true">{{ "Restore tag" }}</WlButton>
</div>
</template>Size and density
Full example
<script setup lang="ts">
import { WlButton, WlTag } from "legato-ui";
import { ref } from "vue";
const visible = ref(true);
</script>
<template>
<div class="wl-stack" data-space="md">
<WlTag
v-if="visible"
removable
color="blue"
tone="info"
icon="check"
size="sm"
remove-label="Remove Design tag"
@remove="visible = false"
>{{ "Design" }}</WlTag>
<WlButton v-else size="sm" @click="visible = true">{{ "Restore tag" }}</WlButton>
</div>
</template>Variants and removable tags
All five colours, removable with a unique removeLabel, controlled array and restoring focus/tags.
tonecolorSelected tags: Design, Development, Review.
The remove event identifies the tag to remove. The application updates the array and restores focus.
Full example
<script setup lang="ts">
import { WlButton, WlTag, type WlTagColor, type WlTone } from "legato-ui";
import { nextTick, ref } from "vue";
const labels = { gray: "Default", blue: "Release", green: "Done", amber: "In progress", red: "Overdue" } satisfies Record<WlTagColor, string>;
const tones = ["neutral", "accent", "info", "success", "warning", "danger"] as const satisfies readonly WlTone[];
const tags = ref(["Design", "Development", "Review"]);
const controls = ref<HTMLElement | null>(null);
async function remove(tag: string): Promise<void> {
tags.value = tags.value.filter((value) => value !== tag);
await nextTick();
controls.value?.querySelector<HTMLButtonElement>("button")?.focus();
}
</script>
<template>
<div class="wl-stack" data-space="lg">
<div class="wl-stack" data-space="xs">
<code>tone</code>
<div class="wl-inline" data-space="sm">
<WlTag v-for="tone in tones" :key="tone" :tone="tone">{{ tone }}</WlTag>
</div>
</div>
<div class="wl-stack" data-space="xs">
<code>color</code>
<div class="wl-inline" data-space="sm">
<WlTag v-for="(label, color) in labels" :key="color" :color="color">{{ label }}</WlTag>
</div>
</div>
<div ref="controls" class="wl-inline" data-space="sm"><WlTag
v-for="tag in tags"
:key="tag"
color="blue"
removable
:remove-label="'Remove tag ' + tag"
@remove="remove(tag)"
>{{ tag }}</WlTag>
<WlButton
size="sm"
variant="ghost"
@click="tags = ['Design', 'Development', 'Review']"
>{{ "Restore tags" }}</WlButton>
</div>
<p class="wl-text-small" role="status">{{ "Selected tags:" }} {{ tags.join(', ') || "none" }}.</p>
<p class="wl-text-small wl-text-muted">{{ "The remove event identifies the tag to remove. The application updates the array and restores focus." }}</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 |
|---|---|---|---|
color | string | "gray" | Palette color, independent of semantic tone. |
tone | WlTone | Not set | Semantic tag color. |
removable | boolean | false | Show the remove button. |
removeLabel | string | Not set | Accessible remove button name; falls back to WlConfig.locale.remove (Remove in English). |
pt | WlPt< | Not set | Attributes of internal Legato UI elements. |
icon | WlIconInput | Not set | Icon name or supported custom icon descriptor. |
size | WlSizeSm | "md" | Size within the component family's documented scale. |
density | WlDensity | "default" | Spacing density for this component family. |
disabled | boolean | false | Disable user interaction with this component. |
Events
| Event | Payload | When emitted |
|---|---|---|
remove | [event: MouseEvent] | Remove button click. |
Slots
| Slot | Type / values | Content |
|---|---|---|
default | default?(props: Record< | Tag text. |
icon | icon?(props: Record< | Custom icon content. |
removeIcon | removeIcon?(props: Record< | Custom graphic inside the named removal action. |
Pass-through: pt
Sections WlTag 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 | The root section in WlConfig.pt.tag configuration. |
icon | span.wl-tag__icon | Decorative component icon. |
label | span.wl-tag__text | The label section in WlConfig.pt.tag configuration. |
removeButton | button.wl-tag__remove | Button that removes the associated value or file. |
removeIcon | span | Decorative remove icon. |
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
- A regular tag is a text label; only removable adds a native button.
- Give every removable tag a unique removeLabel that includes its name.
- Remove emits an event: update the list and move focus to the next action when deleting a focused tag.
Keyboard and application responsibilities
| Key | Action |
|---|---|
| Tab / Shift+Tab | Move between enabled links, actions and form controls. |
| Enter / Space | Activate native actions; links follow with Enter. |
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.