Skip to content

Now in the official shadcn registry directory.

Start free

Badge

A small status label with a variant × tone × size matrix: 3 variants, 6 tones, 3 sizes, plus asChild composition.

display
A free styled version is available
LiveDegradedv2.4.03

Installation

Run the following command

npx shadcn@latest add @ai2/badge

Dependencies, the @ai2/tokens theme and the component file are installed together.

Usage

TS
import { Badge } from "@/components/ui/badge"

<Badge variant="outline" tone="success">
  Live
</Badge>

All three axes are optional. Omit them and you get the neutral soft medium badge. Any combination of the axes is valid.

Examples

Variants

SolidSoftOutline

Use soft for status pills, solid for counts and outline for subtle tags.

Tones

NeutralBrandSuccessWarningDangerInfo

Tones combine with every variant: variant="outline" tone="danger" is a prop pair, not custom CSS.

Sizes

SmallMediumLarge

sm (h-5) fits dense tables, md (h-6) is the default, and lg (h-7) suits standalone tags.

As child

With asChild, the badge must have exactly one element child, useful for linkable version tags and filters.

Props

Badge also accepts every native <span> prop.

PropTypeDefaultDescription
variant"solid" | "soft" | "outline""soft"Visual style of the badge.
tone"neutral" | "brand" | "success" | "warning" | "danger" | "info""neutral"Semantic color channel, mapped to theme tokens.
size"sm" | "md" | "lg""md"Height, padding and radius scale.
asChildbooleanfalseMerges props onto the child element (e.g. a Link) instead of rendering a native span.

ai2 Badge: tone-driven status labels for React

The ai2 Badge is a shadcn-compatible react badge component styled with Tailwind CSS v4. It is the smallest tone-aware surface in the system: 3 variants, 6 tones and 3 sizes make 54 combinations for status pills, counts, version tags and category chips. A green "Live" indicator or a red error count is a prop pair, not custom CSS.

It ships through the shadcn registry format, so you install it with one CLI command, an MCP agent, or a copy-paste, and the TypeScript source lands in your own project. You own the file; there is no runtime dependency on ai2 itself. The live example above is the exact component you get.

What is the ai2 Badge?

A single Badge component (rendered as a span) plus an exported badgeVariants cva function. Three typed axes drive the look: variant (solid, soft, outline), tone (neutral, brand, success, warning, danger, info) and size (sm, md, lg). The default is a neutral soft medium badge.

The six tones are what make it an indicator, not just a label: success for healthy states, warning for degraded ones, danger for failures, info for notices, brand for product accents and neutral for everything else. Each tone resolves to the ai2 token file, so badges follow your theme in light and dark mode, and asChild lets a badge render as a link or any other element.

Why use it

  • Semantic tones for status: Status UIs live and die by consistent color coding. The six tones map to the same semantic tokens as Button and Alert, so "success" is the same green everywhere in your product.
  • Three intensities per tone: solid for high-emphasis counts, soft for the classic status pill, outline for subtle tags. Same tone, three volumes.
  • Linkable via asChild: asChild merges the badge styling onto a child element, so version tags and filter chips can be real anchors without wrapper hacks.
  • Icon-ready sizing: svg children are sized to size-3 with a built-in gap, so a dot or check icon sits correctly next to the label with no extra classes.
  • Agent-readable metadata: The registry item describes the variant matrix and intended use in plain words, so an MCP agent can pick the right tone without guessing.

Features

  • 3 variants x 6 tones x 3 sizes: 54 combinations generated by cva compound variants, all resolved from theme tokens rather than hardcoded colors.
  • Soft default: The default variant is soft with the neutral tone, the most common status-pill look, so the zero-prop badge is already useful.
  • asChild composition: Built on the radix Slot primitive, the badge can render as a Next.js Link, an anchor or any single element child.
  • Data attributes for styling: The root exposes data-slot="badge" and data-tone, so you can restyle specific tones from CSS without forking the component.
  • Whitespace-safe layout: w-fit, shrink-0 and whitespace-nowrap keep badges from collapsing or wrapping inside flex rows and table cells.
  • TypeScript source: The file you install is typed end to end, including the exported badgeVariants function for use on other elements.

Production tips

  • Keep one tone per meaning: Decide once what success, warning and danger mean in your product (deploy states, payment states) and reuse the mapping everywhere. Mixed meanings destroy scannability.
  • Do not rely on color alone: Pair the tone with a label ("Live", "Failed") or an icon. Color-blind users and monochrome contexts need the text to carry the meaning.
  • Use sm in dense tables: The sm size (h-5) keeps rows compact; md (h-6) reads better in cards and headers, and lg (h-7) suits standalone tags. Keep one size per column.
  • Prefer outline for passive tags: Categories and metadata read best as outline badges; reserve solid and soft tones for states that can change, so movement catches the eye.
  • Counts belong in solid: Notification counts and totals get the strongest contrast from variant="solid", especially solid danger for error counts.

Works with the rest of ai2

Badges annotate almost everything in the registry. Put one next to a trigger in an ai2 Accordion to show counts, in an ai2 Avatar stack for presence, or in ai2 Table cells for row status.

For richer surfaces, drop badges into ai2 Card headers for plan tiers, or next to ai2 Tabs labels for unread counts. Everything shares one token source, so a danger badge inside a success alert still resolves to the same palette in both modes.

FAQs

Get new components in your inbox

Component drops, new themes and release notes. No spam, and you can unsubscribe from any email.

© 2026 ai2 design system · MIT licensed · Built with its own components