Skip to content
ShineUI
Install

Badge

Counts and presence.

<sui-badge>MiscStable

About

Small count or status marker: unread on a nav item, due on a tab, a dot for presence beside a name. Three emphasis roles, brand, accent and soft, plus the shared status ladder of positive, info, attention, critical and neutral. To pin a count to the corner of another element, use sui-overlay-badge.

Usage

<sui-badge value="12"></sui-badge> <script type="module"> import { defineCustomElements } from "@shineui/core/loader"; import "@shineui/core/shineui.css"; defineCustomElements(); </script>
import { SuiBadge } from "@shineui/react"; import "@shineui/core/shineui.css"; export function Example() { return <SuiBadge value="12" />; }
<script setup> import { SuiBadge } from "@shineui/vue"; import "@shineui/core/shineui.css"; </script> <template> <SuiBadge value="12" /> </template>
import { Component } from "@angular/core"; import { SuiBadge } from "@shineui/angular"; @Component({ standalone: true, imports: [SuiBadge], template: `<sui-badge value="12"></sui-badge>`, }) export class Example { }

Basic

The badge is a plain span with no role, so the count is read as text where it sits. Put the meaning in the label beside it, as in "Unread 12", and never leave the number to stand alone.

Unread
<span style="display:flex;gap:8px;align-items:center;font:520 13px/1.4 var(--font-sans);color:var(--ink)">Unread <sui-badge value="12"></sui-badge></span>

Severities

Three emphasis roles (brand, accent, soft) and the shared status ladder (positive, info, attention, critical, neutral); an unknown severity falls back to brand. Brand mode shows no green or red, so positive and info sit on the brand hue and attention and critical on the accent; semantic mode adds green, gold and rose.

<div style="display:flex;flex-wrap:wrap;gap:14px;align-items:center"> <sui-badge value="9"></sui-badge> <sui-badge value="9" severity="accent"></sui-badge> <sui-badge value="12" severity="soft"></sui-badge> <sui-badge value="3 paid" severity="positive"></sui-badge> <sui-badge value="new" severity="info"></sui-badge> <sui-badge value="2 due" severity="attention"></sui-badge> <sui-badge value="!" severity="critical"></sui-badge> <sui-badge value="0" severity="neutral"></sui-badge> </div>

Sizes and the dot

sm is 16px with 10px text, md is 19px with 11px text. The 8px dot announces nothing, so name the element it marks for the change. Shape follows severity, so state reads without hue: positive a filled disc, info a hollow ring, attention a ring with a center point, critical a disc with a halo, neutral a rounded square.

Numbers use tabular numerals, so counts stay aligned in a column.
<div style="display:flex;flex-wrap:wrap;gap:14px;align-items:center"> <sui-badge value="7" size="sm"></sui-badge> <sui-badge value="7"></sui-badge> <sui-badge value="128" severity="soft" size="sm"></sui-badge> <sui-badge dot severity="accent"></sui-badge> <sui-badge dot severity="positive"></sui-badge> <sui-badge dot severity="info"></sui-badge> <sui-badge dot severity="attention"></sui-badge> <sui-badge dot severity="critical"></sui-badge> <sui-badge dot severity="neutral"></sui-badge> <span style="font:460 12px/1.6 var(--font-sans);color:var(--ink-faint)">Numbers use tabular numerals, so counts stay aligned in a column.</span> </div>

On nav and tabs

The job the badge exists for: an open count on a register, a due count on a tab. A presence dot rides beside a name that already carries the meaning.

Bills Approvals Bank feed Dana Whitfield is online
<div style="display:grid;gap:10px;max-width:280px"> <span style="display:flex;gap:8px;align-items:center;font:520 13px/1.4 var(--font-sans);color:var(--ink)">Bills <sui-badge value="9" severity="soft" style="margin-left:auto"></sui-badge></span> <span style="display:flex;gap:8px;align-items:center;font:520 13px/1.4 var(--font-sans);color:var(--ink)">Approvals <sui-badge value="2 due" severity="attention" style="margin-left:auto"></sui-badge></span> <span style="display:flex;gap:8px;align-items:center;font:520 13px/1.4 var(--font-sans);color:var(--ink)">Bank feed <sui-badge value="!" severity="critical" style="margin-left:auto"></sui-badge></span> <span style="display:flex;gap:8px;align-items:center;font:520 13px/1.4 var(--font-sans);color:var(--ink)"><sui-badge dot severity="accent"></sui-badge> Dana Whitfield is online</span> </div>

API

<sui-badge>

Properties

PropertyAttributeTypeDefaultDescription
dotdotbooleanfalsePresence dot (8px) instead of a pill; value is not rendered. The dot paints the severity's solid color, not its soft wash, because a tint disc on the surface reads as nothing, and its shape follows the severity so the state reads without hue: positive a filled disc, info a hollow ring, attention a ring with a center point, critical a disc with a halo, neutral a rounded square.
severityseveritySuiBadgeSeverity"accent" | "attention" | "brand" | "critical" | "info" | "neutral" | "positive" | "soft"'brand'Color role: brand, accent, soft (brand on brand-soft) or the status ladder, painted from the same status tokens as the tag and the message band. Unknown values fall back to brand.
sizesize"md" | "sm"'md'Pill height: sm 16px / 10px text, md 19px / 11px text. Reflected.
valuevaluenumber | string | undefinedCount or short text shown in the pill, in tabular numerals. Ignored in dot mode.

Types

SuiBadgeSeverity typeThe shared status ladder plus the three emphasis roles a count badge also needs.
No members.
SuiSeverity type
No members.

Theming

Every design token this element can render with, read from its own stylesheets and the ones it imports. Set a token on :root or on any ancestor and every use below follows it. The values shown are the ones in the theme you are viewing. The list is read per stylesheet, so an element that imports a shared drawing module lists that module's tokens too, whether or not it paints with all of them.

See also