Skip to content

Badge

Data displaySince 0.9.0

A short, static label such as “Active”, “Beta”, or “3 new” that classifies the content next to it. Badge renders an optional decorative dot or icon and the label. The label carries the meaning; tone colors, the dot, and the icon are decorative, so a badge never depends on color alone. Badges are not interactive: removable or selectable tags are Tag Group.

  • Five tonesNeutral, info, success, warning, and error, in subtle or outline style.
  • Dot or iconA status dot or any icon in front of the label.
  • Two sizesSmall and medium sizes for tables, lists, and headers.
  • Plain text labelThe label is real text, so screen readers read it in context.

Use it for

  • Status or category of an item in a list, table cell, card, or heading: Active, Draft, Overdue, Beta.
  • A count that belongs to a label, such as ‘3 new’ beside a section title.

Use something else for

  • Tags the user can remove or select: use Tag Group.
  • Status that changes while the user works and must be announced: use Inline Message with live set.
  • Messages that need explanation or actions: use Alert.
Anatomy
<span class="aui-badge aui-badge--{tone} aui-badge--{variant} aui-badge--{size}">
<span class="aui-badge__dot | aui-badge__icon" aria-hidden="true">(dot or icon, optional)</span>
<span class="aui-badge__label">label</span>
</span>

Use the bar above each frame to switch theme, density, direction, and locale.

The part of the Team profile showcase that uses Badge. Change its options, use it with the keyboard, and watch the event log; the link in the frame opens the full showcase. The bar above the frame switches theme, density, direction, and locale.

Showcase source
// Layout and content showcase: a team profile page built with the layout primitives, cards,
// typography, badges, keyboard keys, avatars, an avatar group, and a tag group.
import { Avatar } from '@absoluteui/components/avatar';
import { AvatarGroup } from '@absoluteui/components/avatar-group';
import { Badge } from '@absoluteui/components/badge';
import { Card } from '@absoluteui/components/card';
import { Kbd } from '@absoluteui/components/kbd';
import { Container, Divider, Flex, Grid, Stack } from '@absoluteui/components/layout';
import { TagGroup, type TagGroupChangeDetail } from '@absoluteui/components/tag-group';
import { Heading, Link, Text } from '@absoluteui/components/typography';
import { annotate, choice, createShowcase, hostIn, toggle } from './kit.js';
const sc = createShowcase({
title: 'Team profile',
description: 'Layout primitives and content components composing a real page. Resize the frame: the grid reflows.',
});
const page = hostIn(sc.stage);
Container.apply(page, { size: 'lg' });
const stack = Stack.apply(page, { gap: 6 });
// Each block of the page declares its components (focus mode shows a component's own blocks).
// Header.
const header = annotate(hostIn(page), ['layout', 'avatar', 'typography', 'badge']);
const headerFlex = Flex.apply(header, { gap: 4, align: 'center', wrap: true });
const avatar = Avatar.create(hostIn(header), { name: 'Platform Engineering', size: 'xl', shape: 'square', icon: 'code' });
const titles = hostIn(header);
Stack.apply(titles, { gap: 1 });
titles.append(Heading.create(2, 'Platform Engineering', { size: 3 }), Text.create('Builds and runs the internal developer platform.', { tone: 'muted' }));
const badges = hostIn(titles);
Flex.apply(badges, { gap: 2, wrap: true });
const badgeList = [
Badge.create(hostIn(badges), { label: 'Hiring', tone: 'success', dot: true }),
Badge.create(hostIn(badges), { label: '14 members', tone: 'neutral' }),
Badge.create(hostIn(badges), { label: 'On call', tone: 'warning', variant: 'outline', icon: 'clock' }),
];
// Members grid of cards.
const members = annotate(hostIn(page), ['layout', 'card', 'avatar', 'typography']);
Stack.apply(members, { gap: 4 });
members.append(Divider.create({ label: 'Members' }));
const grid = hostIn(members);
const gridLayout = Grid.apply(grid, { columns: 'auto', minColumnWidth: '14rem', gap: 4 });
const MEMBERS = [
{ name: 'Ada Kowalski', role: 'Engineering lead', status: 'online' },
{ name: 'Bruno Silva', role: 'Site reliability', status: 'busy' },
{ name: 'Chen Wei', role: 'Backend engineer', status: 'away' },
{ name: 'Divya Nair', role: 'Frontend engineer', status: 'offline' },
] as const;
const cards = MEMBERS.map((m) => {
const content = document.createElement('div');
Flex.apply(content, { gap: 3, align: 'center' });
Avatar.create(hostIn(content), { name: m.name, status: m.status, size: 'md' });
const who = document.createElement('div');
who.append(Text.create(m.name, { strong: true }), Text.create(m.role, { tone: 'muted', size: 'sm' }));
content.append(who);
return Card.create(hostIn(grid), { content, variant: 'raised', headingLevel: 3 });
});
// Skills and shortcuts.
const details = hostIn(page);
Grid.apply(details, { columns: 'auto', minColumnWidth: '16rem', gap: 4 });
const skillsBody = document.createElement('div');
const tags = TagGroup.create(hostIn(skillsBody), {
label: 'Team skills',
removable: true,
selection: 'multiple',
value: ['kubernetes'],
items: [
{ value: 'kubernetes', label: 'Kubernetes' },
{ value: 'terraform', label: 'Terraform' },
{ value: 'go', label: 'Go' },
{ value: 'observability', label: 'Observability' },
{ value: 'security', label: 'Security' },
],
});
annotate(Card.create(hostIn(details), { title: 'Skills', content: skillsBody, headingLevel: 3 }).host, ['layout', 'card', 'tag-group']);
const shortcutsBody = document.createElement('dl');
shortcutsBody.className = 'sc-shortcuts';
for (const [keys, text] of [
['Mod+K', 'Search'],
['Mod+Shift+P', 'Command palette'],
['?', 'Show shortcuts'],
] as const) {
const dt = document.createElement('dt');
Kbd.create(dt, { hotkey: keys });
const dd = document.createElement('dd');
dd.textContent = text;
shortcutsBody.append(dt, dd);
}
annotate(Card.create(hostIn(details), { title: 'Shortcuts', content: shortcutsBody, headingLevel: 3 }).host, ['layout', 'card', 'kbd']);
const footer = annotate(hostIn(page), ['layout', 'avatar-group', 'typography']);
Flex.apply(footer, { gap: 3, align: 'center', justify: 'between', wrap: true });
const group = AvatarGroup.create(hostIn(footer), { label: 'Recently active', max: 4, items: ['Ada Kowalski', 'Bruno Silva', 'Chen Wei', 'Divya Nair', 'Emeka Obi', 'Farah Haddad', 'Grace Liu'].map((name) => ({ name })) });
footer.append(Link.create({ href: 'https://example.com/platform', text: 'Team handbook', external: true }));
sc.listen(tags.host, ['aui-change', 'aui-remove'], 'tags');
tags.host.addEventListener('aui-change', (e) => {
sc.log('selected skills', (e as CustomEvent<TagGroupChangeDetail>).detail.value);
});
choice(
sc,
'Spacing',
[
{ value: '4', label: 'Compact' },
{ value: '6', label: 'Comfortable' },
{ value: '10', label: 'Spacious' },
],
'6',
(g) => {
const gap = Number(g) as 4 | 6 | 10;
stack.update({ gap });
gridLayout.update({ gap: gap === 10 ? 8 : 4 });
headerFlex.update({ gap: gap === 10 ? 6 : 4 });
},
['layout'],
);
choice(
sc,
'Avatar shape',
[
{ value: 'square', label: 'Square' },
{ value: 'circle', label: 'Circle' },
],
'square',
(shape) => {
avatar.update({ shape });
group.update({ shape });
},
['avatar', 'avatar-group'],
);
toggle(sc, 'Outline badges', false, (outline) => {
for (const b of badgeList) b.update({ variant: outline ? 'outline' : 'subtle' });
}, ['badge']);
toggle(sc, 'Sunken cards', false, (sunken) => {
for (const c of cards) c.update({ variant: sunken ? 'sunken' : 'raised' });
}, ['card']);
import { Badge, type BadgeTone } from '@absoluteui/components/badge';
const row = document.createElement('p');
document.body.append(row);
const statuses: [string, BadgeTone][] = [['Draft', 'neutral'], ['In review', 'info'], ['Active', 'success'], ['Expiring', 'warning'], ['Overdue', 'error']];
for (const [label, tone] of statuses) {
const host = document.createElement('span');
row.append(host, ' ');
Badge.create(host, { label, tone, dot: true });
}
import { Badge } from '@absoluteui/components/badge';
const heading = document.createElement('h3');
heading.textContent = 'Release notes ';
const beta = document.createElement('span');
heading.append(beta);
document.body.append(heading);
Badge.create(beta, { label: 'Beta', tone: 'info', variant: 'outline', size: 'sm', icon: 'info' });
Terminal window
npm install @absoluteui/components @absoluteui/core @absoluteui/theme

Registry setup, the theme stylesheet, and the Content Security Policy are covered in Installation.

import { Badge } from '@absoluteui/components/badge';
import '@absoluteui/components/badge/style.css';
import { Badge } from '@absoluteui/components/badge';
import '@absoluteui/components/badge/style.css';
const host = document.querySelector<HTMLElement>('#plan');
if (host) Badge.create(host, { label: 'Beta', tone: 'info', variant: 'outline', size: 'sm' });
More usage
import { Badge } from '@absoluteui/components/badge';
const host = document.querySelector<HTMLElement>('#status');
if (host) {
const status = Badge.create(host, { label: 'Active', tone: 'success', dot: true });
status.update({ label: 'Suspended', tone: 'warning' });
}

Using Angular? See Badge for Angular.

Badge.create(host: HTMLElement, options: BadgeOptions): Badge

Global configuration key: badge (see Configuration).

Option Type Default Description
label string Visible text; carries the meaning. Required.
tone 'neutral' | 'info' | 'success' | 'warning' | 'error' "neutral" Decorative tone color.
variant 'subtle' | 'outline' "subtle" subtle: tone fill; outline: tone boundary. Globally configurable.
size 'sm' | 'md' "md" Badge size. Globally configurable.
icon IconRef | null Decorative icon before the label.
dot boolean "false" Decorative status dot before the label (not with icon).
Property Type Description
host HTMLElement The host element (receives the classes).
label string Current label.
options Readonly<BadgeOptions> Current options.
Method Description
update(options: Partial<BadgeOptions>): void Merge and apply options.
destroy(): void Remove rendering, classes, and the configuration subscription.

All rules live in the aui.components cascade layer, so application styles override them without specificity battles.

Class Purpose
aui-badge Host.
aui-badge--neutral | --info | --success | --warning | --error Tone modifiers.
aui-badge--subtle | --outline Variant modifiers.
aui-badge--sm | --md Size modifiers.
aui-badge__dot Decorative status dot.
aui-badge__icon Decorative icon.
aui-badge__label Label text.

Tokens this stylesheet reads (verified in CI). Override them in a theme or with the Theme Designer.

--aui-border-width | --aui-color-border-strong | --aui-color-error-fg | --aui-color-error-subtle | --aui-color-info-fg | --aui-color-info-subtle | --aui-color-success-fg | --aui-color-success-subtle | --aui-color-surface | --aui-color-surface-sunken | --aui-color-text | --aui-color-text-muted | --aui-color-warning-fg | --aui-color-warning-subtle | --aui-font-family-sans | --aui-font-size-sm | --aui-font-size-xs | --aui-font-weight-medium | --aui-icon-size-sm | --aui-line-height-tight | --aui-radius-pill | --aui-space-1 | --aui-space-2

TypeScript definitions
type BadgeTone = 'neutral' | 'info' | 'success' | 'warning' | 'error';
type BadgeVariant = 'subtle' | 'outline';
type BadgeSize = 'sm' | 'md';
interface BadgeConfig { variant: BadgeVariant; size: BadgeSize }
interface BadgeOptions extends Partial<BadgeConfig> {
label: string;
tone?: BadgeTone;
icon?: IconRef | null;
dot?: boolean;
}

Pattern: Static text: no role; the label is read in document order with the content it classifies.

Checked on every docs build: the showcase passes axe (WCAG 2.2 A and AA rules) in the default, dark, and high-contrast themes and right to left; the playground loads without errors and passes axe before and after every on/off option is switched, with no Content Security Policy violations.

Key Context Action
None Any Not focusable; read in document order by assistive technology.
Element Role
host none (inline text)
dot and icon none (aria-hidden=true)
Attribute Element Value
aria-hidden dot and icon true (decorative)

Never receives or moves focus.

Criterion Level Note
1.3.1 Info and Relationships A
1.4.1 Use of Color A
1.4.3 Contrast (Minimum) AA
1.4.11 Non-text Contrast AA

Automated test results: Accessibility and compliance.

  • The label carries the meaning; tone colors, the dot, and the icon are decorative, so meaning never depends on color alone.
  • A badge that changes while the user works is not announced; use Inline Message with live set for that.
  • Manual screen-reader verification (NVDA, JAWS, VoiceOver) is pending.
Import cost Minified gzip brotli CSS brotli
@absoluteui/components/badge 31.1 kB 10.8 kB 9.6 kB 0.7 kB

Measured at build time, including every AbsoluteUI module the component pulls in. No third-party runtime dependencies.

Budget (enforced in CI) Limit
Badge.create, per instance < 1 ms average in headless Chromium

Tested scale: Unit-tested per instance; not data-driven.

Constant work per render: class toggles, one optional icon, and one text update.

Measured run times: Performance.

States

Tones neutral, info, success, warning, error; variants subtle and outline; sizes sm and md; with a dot or an icon.

State transitions
From Trigger To
any update({ tone, variant, size, label }) new appearance and label
any global configuration change variant and size follow the configuration unless set on the instance
any destroy() host restored to empty
Accessibility notes
  • Write labels that make sense without color: “Overdue”, not a red dot alone.
  • A badge is not announced when it changes. For status that changes while the user works, use Inline Message with live.
  • The e2e axe run covers the default, dark, and high-contrast themes; manual screen-reader verification is pending.
Responsive behavior

An inline-flex pill limited to the container width; a long label is truncated with an ellipsis. Keep labels to one or two words.

Right-to-left

Logical properties: the dot or icon sits at the inline start.

Theming

Subtle badges pair color-text with color-{tone}-subtle (or color-surface-sunken for neutral); outline badges pair color-text with color-surface. These pairs are in the contrast gate. Forced-colors mode draws a CanvasText boundary and dot.

Global configuration
configureAbsoluteUI({ components: { badge: { variant: 'outline', size: 'sm' } } });
Component configuration

Instance variant and size override global and theme configuration. Configuration changes re-render existing badges.

Icons

icon takes any registered icon name or icon definition; it is decorative.

Security

The label uses textContent; it is never parsed as HTML. CSP-safe.

Data handling

No persistence, network access, or telemetry.

Supported data scale

Not data-driven. Hundreds of badges on a page (for example one per table row) are fine.

Edge cases
  • dot: true together with an icon is rejected; use one decoration.
  • icon: null removes the icon; the dot shows again only when dot is true.
  • Safe in renderers that discard nodes without calling destroy(), such as Data Table cells: the configuration subscription holds the instance weakly, so a discarded badge is released.
Errors
Code Category Cause
BADGE_OPTIONS configuration Missing or blank label, unknown tone, non-boolean dot, or dot combined with icon.
ICON_UNKNOWN configuration Unknown icon.
CFG_INVALID_VALUE / CFG_UNKNOWN_OPTION configuration Invalid variant or size, or unknown configuration.

Invalid options throw before the host is modified; an invalid update() leaves the previous state intact.

Known limitations
  • Text only.
  • Manual screen-reader verification is pending.
Unsupported scenarios
  • Interactive badges (click, remove, select): use Tag Group or Button.
  • HTML or Node content.