v0.0.2
Demos (demo panel, opens in a new tab)

Badge

A small, rounded label that shows a status, a category or a count.

zb:badge zubazar/ui · free (MIT)

Color and fill

Color and fill: view
BLADE

Pick the color with variant; solid fills the badge with the color itself, and the default is the gray secondary.

variant
solid
blade
<zb:badge variant="secondary" :solid="false">Pending</zb:badge>
blade
<zb:badge variant="secondary" :solid="true">Pending</zb:badge>
blade
<zb:badge variant="primary" :solid="false">Pending</zb:badge>
blade
<zb:badge variant="primary" :solid="true">Pending</zb:badge>
blade
<zb:badge variant="success" :solid="false">Pending</zb:badge>
blade
<zb:badge variant="success" :solid="true">Pending</zb:badge>
blade
<zb:badge variant="warning" :solid="false">Pending</zb:badge>
blade
<zb:badge variant="warning" :solid="true">Pending</zb:badge>
blade
<zb:badge variant="danger" :solid="false">Pending</zb:badge>
blade
<zb:badge variant="danger" :solid="true">Pending</zb:badge>
blade
<zb:badge variant="info" :solid="false">Pending</zb:badge>
blade
<zb:badge variant="info" :solid="true">Pending</zb:badge>
blade
<zb:badge variant="dark" :solid="false">Pending</zb:badge>
blade
<zb:badge variant="dark" :solid="true">Pending</zb:badge>
PropValues
variantprimary | secondary | success | danger | warning | info | dark
solidtrue | false (filled)

With an icon or a dot

With an icon or a dot: view
BLADE

Put a small zb:icon or a colored dot before the text; still state the status in words.

blade
<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

As a counter: view
BLADE

To show the number of pending tasks or unread notifications next to a button or a heading, place the badge inside the text.

blade
<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?

PropTypeDefaultDescription
variant—secondaryprimary · secondary · success · danger · warning · info · dark (brand = primary, neutral = secondary); an unknown value falls back to secondary
solidbooleanfalseFills 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

Events, hooks and details
  • Use primary for 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.
Zubazar UI · ZubazarDesigned for people.