WlBadge
Appearance
Full example
<div class="wl-stack" data-space="md">
<WlBadge :value="12" />
</div>Counter
Full example
<div class="wl-stack" data-space="md">
<WlBadge :value="12" />
</div>Numbers, text and dots
All semantic tones, a dot with text context, zero count and marking read locally.
Full example
<script setup lang="ts">
import { WlBadge, WlButton, type WlTone } from "legato-ui";
import { ref } from "vue";
const values = { neutral: "12", accent: "3", info: "1", success: "OK", warning: "5", danger: "9" } satisfies Record<WlTone, string>;
const unread = ref(3);
</script>
<template>
<div class="wl-stack" data-space="lg">
<div class="wl-inline" data-space="md"><span
v-for="(value, variant) in values"
:key="variant"
class="wl-inline"
data-space="xs"
><WlBadge :value="value" :tone="variant" /><span class="wl-text-small">{{ variant }}</span></span></div>
<div class="wl-inline" data-space="md"><span
v-for="(value, variant) in values"
:key="variant"
class="wl-inline"
data-space="xs"
>
<WlBadge dot :tone="variant" aria-hidden="true" />
<span class="wl-text-small">{{ "Status" }} {{ variant }}</span>
</span></div>
<div class="wl-inline" data-space="sm">
<span class="wl-text-body">{{ "Unread:" }} <WlBadge :value="unread" /></span>
<WlButton size="sm" :disabled="unread === 0" @click="unread = 0">{{ "Mark as read" }}</WlButton>
<WlButton size="sm" variant="ghost" @click="unread = 3">{{ "Restore counter" }}</WlButton>
</div>
</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 |
|---|---|---|---|
value | string | | Not set | Value: string | number. |
tone | WlTone | "accent" | Semantic badge color. |
dot | boolean | false | Dot mode (value is ignored). |
pt | WlPt< | Not set | Attributes of internal Legato UI elements. |
max | number | Not set | Display numeric values above this limit as a capped count. |
ariaLabel | string | Not set | Accessible label; required for a meaningful dot indicator. |
Events
No public events.
Slots
| Slot | Type / values | Content |
|---|---|---|
default | default?(props: { value: string | | Custom badge content with the original and displayed values. |
Pass-through: pt
Sections WlBadge 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.badge configuration. |
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
- Value remains text; dot contains no text and must not explain a state alone.
- Associate numeric counts with a nearby object, such as “Unread: 3”.
- Use aria-hidden and an adjacent text label for a decorative dot; tone colour does not replace meaning.
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.