Skip to content
Vertical Jump Designs-uiFront-End Studio
Get Pro

v3.9 is out.

Data display

Badge

Free1.8 KB gzipped

A small, non-interactive status or label pill. Use it for statuses ("Final", "Live"), categories, and counts. Always give it text or an icon plus text, so its meaning never depends on color alone.

Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · No keyboard interaction of its own · Full report

Import

tsx
import { Badge, BadgeAnchor } from "@vjdesigns/vjdesigns-ui";

Importing only Badge adds about 1.8 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.

Examples

Variants and tones

neutralprimaryaccentsuccesswarningdangerinfo
neutralprimaryaccentsuccesswarningdangerinfo
neutralprimaryaccentsuccesswarningdangerinfo
tsx
import { Badge, Flex, Stack } from "@vjdesigns/vjdesigns-ui";

export function VariantsAndTones() {
  const tones = ["neutral", "primary", "accent", "success", "warning", "danger", "info"] as const;
  return (
    <Stack gap={3} align="center">
      {(["soft", "solid", "outline"] as const).map((variant) => (
        <Flex key={variant} gap={2} wrap="wrap" justify="center">
          {tones.map((tone) => (
            <Badge key={tone} variant={variant} tone={tone}>
              {tone}
            </Badge>
          ))}
        </Flex>
      ))}
    </Stack>
  );
}

Inverse

inverse swaps the solid colors, for a badge on a solid tone surface such as a solid Navbar, a Banner or a primary card. It uses the same verified color pair as solid, so it keeps its contrast in both themes.

neutral3 neutral items
primary3 primary items
accent3 accent items
success3 success items
warning3 warning items
danger3 danger items
info3 info items
tsx
import { Badge, Flex } from "@vjdesigns/vjdesigns-ui";

export function Inverse() {
  const tones = ["neutral", "primary", "accent", "success", "warning", "danger", "info"] as const;
  return (
    <Flex gap={2} wrap="wrap" justify="center">
      {tones.map((tone) => (
        <div
          key={tone}
          style={{
            display: "flex",
            gap: "var(--space-2)",
            alignItems: "center",
            padding: "var(--space-2) var(--space-3)",
            borderRadius: "var(--radius-lg)",
            background: `var(--color-${tone})`,
            color: `var(--color-on-${tone})`,
          }}
        >
          {tone}
          <Badge variant="inverse" tone={tone} count={3} label={`3 ${tone} items`} />
        </div>
      ))}
    </Flex>
  );
}

Status and counts

dot marks a status; count shows a number capped at max.

ActivePending8 new messages240 alertsNew
tsx
import { Badge, Flex } from "@vjdesigns/vjdesigns-ui";

export function StatusAndCounts() {
  return (
    <Flex gap={3} wrap="wrap" justify="center" align="center">
      <Badge dot tone="success">
        Active
      </Badge>
      <Badge dot tone="warning">
        Pending
      </Badge>
      <Badge tone="primary" variant="solid" count={8} label="8 new messages" />
      <Badge tone="danger" variant="solid" count={240} max={99} label="240 alerts" />
      <Badge caps tone="accent" variant="solid">
        New
      </Badge>
    </Flex>
  );
}

Anchored

BadgeAnchor pins a badge to the corner of another element, like a notification count on an icon button.

3 unread notificationsNew mail
tsx
import {
  BadgeAnchor,
  BellIcon,
  Flex,
  IconButton,
  MailIcon,
} from "@vjdesigns/vjdesigns-ui";

export function Anchored() {
  return (
    <Flex gap={6} align="center">
      <BadgeAnchor count={3} label="3 unread notifications">
        <IconButton aria-label="Notifications" variant="soft" tone="neutral">
          <BellIcon />
        </IconButton>
      </BadgeAnchor>
      <BadgeAnchor dot tone="danger" label="New mail">
        <IconButton aria-label="Inbox" variant="soft" tone="neutral">
          <MailIcon />
        </IconButton>
      </BadgeAnchor>
    </Flex>
  );
}

Accessibility

A bare "3" means nothing to a screen reader: label gives the badge spoken text ("3 unread messages") and hides the visible number from assistive technology. A dot is decorative, so always pair it with words.

3 unread messagesPayment failed
tsx
import {
  BadgeAnchor,
  Badge,
  Flex,
  IconButton,
  MailIcon,
} from "@vjdesigns/vjdesigns-ui";

export function Accessibility() {
  return (
    <Flex gap={6} align="center" wrap="wrap">
      <BadgeAnchor count={3} label="3 unread messages">
        <IconButton aria-label="Messages" variant="ghost" tone="neutral">
          <MailIcon />
        </IconButton>
      </BadgeAnchor>
      <Badge tone="danger" variant="soft" dot>
        Payment failed
      </Badge>
    </Flex>
  );
}

Translated

Badge text and labels are your own, so translate the label along with the visible text. LocaleProvider sets lang, so the label is read in Japanese.

未読の通知 120 件公開中
tsx
import {
  BadgeAnchor,
  Badge,
  BellIcon,
  Flex,
  IconButton,
  LocaleProvider,
} from "@vjdesigns/vjdesigns-ui";
import ja from "@vjdesigns/vjdesigns-ui/locales/ja";

export function Translated() {
  return (
    <LocaleProvider locale="ja" messages={ja}>
      <Flex gap={6} align="center">
        <BadgeAnchor count={120} max={99} label="未読の通知 120 件">
          <IconButton aria-label="通知" variant="ghost" tone="neutral">
            <BellIcon />
          </IconButton>
        </BadgeAnchor>
        <Badge tone="success" variant="soft" dot>
          公開中
        </Badge>
      </Flex>
    </LocaleProvider>
  );
}

Right to left

The first example again, inside a right-to-left LocaleProvider (Arabic). Layout, spacing and arrow icons mirror, and the components' built-in text is translated. The example's own text stays in English.

Variants and tones

neutralprimaryaccentsuccesswarningdangerinfo
neutralprimaryaccentsuccesswarningdangerinfo
neutralprimaryaccentsuccesswarningdangerinfo
tsx
import { LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";

// VariantsAndTones is the "Variants and tones" example above.
<LocaleProvider locale="ar" messages={ar}>
  <VariantsAndTones />
</LocaleProvider>

Usage notes

Renders a <span> with no role. For counts, pass label (e.g. "3 unread messages") so screen readers hear more than a bare number.

API reference

Badge

Badge props
PropTypeDefault
radius

Corner rounding.

"none""xs""sm""md""lg""xl""2xl""pill""pill"
startIcon

Decorative icon before the text. Hidden from assistive technology, so the text must carry the meaning.

ReactNode—
dot

Shows a small leading status dot in the current text color. Decorative: pair it with text.

booleanfalse
caps

Uppercase display type with wide tracking and heavy weight: the athletic "jersey" look.

booleanfalse
children

The badge text. Ignored when count is set.

ReactNode—
variant

Visual style.

"solid""soft""outline""inverse""solid" on `BadgeAnchor`, "soft" on `Badge`
tone

Semantic color.

"neutral""primary""accent""success""warning""danger""info""neutral" on `Badge`, "accent" on `BadgeAnchor`
size

Height, padding, and type size.

"sm""md""lg""md"
count

A number to show instead of children. Rendered with tabular figures and capped at max.

number—
max

Largest count shown before it collapses to "{max}+".

number99
showZero

Show the badge when count is 0. When false, a zero count renders nothing (or hides the anchored badge).

booleanfalse
label

Accessible text that replaces the visible content for screen readers, e.g. "3 unread messages" for a badge that shows 3. Rendered with VisuallyHidden; the visible content is then aria-hidden.

string—

Also accepts native <span> attributes, plus className, style and ref.

BadgeAnchor

Pins a count, dot, or short label to a corner of its child. The badge is ringed in --color-bg (override with the --badge-ring-color custom property on a colored surface) so it reads as separate from the anchor.

Accessibility: the badge is decorative by default (aria-hidden) because an interactive anchor should carry the information in its own name, e.g. <IconButton aria-label="Notifications, 3 unread">. For a non-interactive anchor (like an avatar), pass label to add screen-reader text instead. To announce count changes, use one app-level live region, not a live region on every badge.

BadgeAnchor props
PropTypeDefault
childrenRequired

The element the badge is attached to, such as an IconButton or an avatar.

ReactNode—
dot

Show a small dot instead of a count or content. Pass label so its meaning is available to screen readers.

booleanfalse
content

Custom badge content (a short text or icon) when not using count or dot.

ReactNode—
placement

Corner of the anchor to sit on. Logical, so end flips in right-to-left layouts.

"top-end""top-start""bottom-end""bottom-start""top-end"
overlap

Shape of the anchor, so the badge sits on its visible edge.

"rectangle""circle""rectangle"
offset

Nudges the badge from its corner. A single value moves it that far outward on both axes (negative moves inward); a tuple sets [inline, block] separately. Numbers are pixels.

BadgeOffsetValue | [inline: BadgeOffsetValue, block: BadgeOffsetValue]—
invisible

Hide the badge with a springy scale-out. The badge stays mounted so it can animate back in.

booleanfalse
badgeClassName

Extra class for the badge itself (the root class goes on the wrapper).

string—
variant

Visual style.

"solid""soft""outline""inverse""solid" on `BadgeAnchor`, "soft" on `Badge`
tone

Semantic color.

"neutral""primary""accent""success""warning""danger""info""neutral" on `Badge`, "accent" on `BadgeAnchor`
size

Height, padding, and type size.

"sm""md""lg""md"
count

A number to show instead of children. Rendered with tabular figures and capped at max.

number—
max

Largest count shown before it collapses to "{max}+".

number99
showZero

Show the badge when count is 0. When false, a zero count renders nothing (or hides the anchored badge).

booleanfalse
label

Accessible text that replaces the visible content for screen readers, e.g. "3 unread messages" for a badge that shows 3. Rendered with VisuallyHidden; the visible content is then aria-hidden.

string—

Also accepts native <span> attributes, plus className, style and ref.

See what changed in each version in the Changelog.

Accessibility report

Badge targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.

axe-core audit (live)

Running accessibility audit

Checking the examples above…

Lighthouse audit

Light mode

Score 100

35 passed · 0 failed · 30 not applicable · 10 to check by hand

Dark mode

Score 100

35 passed · 0 failed · 30 not applicable · 10 to check by hand

Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.

Built-in behavior

Keyboard

Not focusable, so there's no keyboard interaction of its own.

Roles and states

Roles and states
ElementRoleStates and properties
<span>none (generic)Read as text; give it words, not only a color
BadgeAnchor countnonearia-label on the anchor ("3 unread")

Manual checks

Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.

Manual accessibility checks
CheckWhat to testWCAG 2.2
KeyboardEvery action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck.2.1.1 (A), 2.1.2 (A)
FocusFocus moves in a logical order, is always visible, and isn't hidden behind sticky headers.2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA)
Screen readersNames, roles and states are announced correctly, and status changes are announced without moving focus.1.3.1 (A), 4.1.2 (A), 4.1.3 (AA)
ColorMeaning never depends on color alone; your own colors meet contrast in both modes.1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA)
Zoom and reflowAt 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed.1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA)
Pointer targetsClick and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap.2.5.8 (AA), 2.5.5 (AAA)
MotionAnimations respect the reduced-motion setting.2.3.3 (AAA)