WlTag
Change props to see the result: the example and code use the same settings. “Reset” restores the initial values.
Settings
Palette color, independent of semantic tone.
Semantic tag color.
Accessible remove button name; falls back to WlConfig.locale.remove (Remove in English).
Show the remove button.
Disable user interaction with this component.
Props pt, icon, size, density, models, handlers and slots can be edited in the SFC. See their descriptions in API.
Example
Explore the live example and copy its Vue SFC into your application. Settings on the left can be combined.
Code for your application
Vue SFC · current settings
<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.
Selected tags: Design, Development, Review.
The remove event identifies the tag to remove. The application updates the array and restores focus.
Vue SFC · additional example
<script setup lang="ts">
import { WlButton, WlTag, type WlTagColor } 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 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-inline" data-space="sm">
<WlTag v-for="(label, color) in labels" :key="color" :color="color">{{ label }}</WlTag>
</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>