Badge
A small, rounded label that shows a status, a category or a count.
zb:badge zubazar/ui · free (MIT)
Color and fill
BLADE
Pick the color with variant; solid fills the badge with the color itself, and the default is the gray secondary.
<zb:badge variant="secondary" :solid="false">Pending</zb:badge>
<zb:badge variant="secondary" :solid="true">Pending</zb:badge>
<zb:badge variant="primary" :solid="false">Pending</zb:badge>
<zb:badge variant="primary" :solid="true">Pending</zb:badge>
<zb:badge variant="success" :solid="false">Pending</zb:badge>
<zb:badge variant="success" :solid="true">Pending</zb:badge>
<zb:badge variant="warning" :solid="false">Pending</zb:badge>
<zb:badge variant="warning" :solid="true">Pending</zb:badge>
<zb:badge variant="danger" :solid="false">Pending</zb:badge>
<zb:badge variant="danger" :solid="true">Pending</zb:badge>
<zb:badge variant="info" :solid="false">Pending</zb:badge>
<zb:badge variant="info" :solid="true">Pending</zb:badge>
<zb:badge variant="dark" :solid="false">Pending</zb:badge>
<zb:badge variant="dark" :solid="true">Pending</zb:badge>
| Prop | Values |
|---|---|
variant | primary | secondary | success | danger | warning | info | dark |
solid | true | false (filled) |
With an icon or a dot
BLADE
Put a small zb:icon or a colored dot before the text; still state the status in words.
<div class="flex flex-wrap items-center gap-2">
<zb:badge variant="success"><zb:icon name="check-circle" size="3.5" />Delivered</zb:badge>
<zb:badge variant="danger"><zb:icon name="x-mark" size="3.5" />Canceled</zb:badge>
<zb:badge variant="success"><span class="size-1.5 rounded-full bg-current"></span>Online</zb:badge>
<zb:badge><span class="size-1.5 rounded-full bg-current"></span>Offline</zb:badge>
</div>
As a counter
BLADE
To show the number of pending tasks or unread notifications next to a button or a heading, place the badge inside the text.
<div class="flex flex-wrap items-center gap-3">
<zb:button variant="white">Awaiting approval <zb:badge variant="danger">12</zb:badge></zb:button>
<h3 class="flex items-center gap-2 text-sm font-semibold">New orders <zb:badge variant="primary">4</zb:badge></h3>
</div>
Props
The values the component takes. What are props and slots?
| Prop | Type | Default | Description |
|---|---|---|---|
variant | — | secondary | primary · secondary · success · danger · warning · info · dark (brand = primary, neutral = secondary); an unknown value falls back to secondary |
solid | boolean | false | Fills the badge with the color itself; the text is dark on the light colors, white on the others |
Slots: default: the badge text (an icon or a dot can be added).
Developer notes
- Use
primaryfor labels that report no status but should stand out (such as "New"); show the same status in the same color on every screen. - The old names still work:
brand=primary,neutral=secondary.