WlBadge
Badge with a value or dot.
Change props to see the result: the example and code use the same settings. “Reset” restores the initial values.
Settings
tone
accent
Semantic badge color.
value
Value: string | number. Enter a number here. Set a text label in the SFC.
max
Not set
Display numeric values above this limit as a capped count.
ariaLabel
Accessible label; required for a meaningful dot indicator.
Dot mode (value is ignored).
Props pt, models, handlers and slots can be edited in the SFC. See their descriptions in API.
Example
12
Focus: outside the example · pointer: outside the 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 { WlBadge } from "legato-ui";
</script>
<template>
<div class="wl-stack" data-space="md">
<WlBadge :value="12" />
</div>
</template>Numbers, text and dots
All semantic tones, a dot with text context, zero count and marking read locally.
12neutral3accent1infoOKsuccess5warning9danger
Status neutralStatus accentStatus infoStatus successStatus warningStatus danger
Unread: 3
Vue SFC · additional 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>