|Kit

Badge

Compact inline label. Five variants × eleven colors, sharing Button's accent system but tuned for status chips and counters.

Badge is a display <span> styled with the kit's (variant × color) system. The shape and palette axes mirror Button, so a chip and an action share the same accent language. It composes onto a real control with asChild when a badge needs to be clickable.

import { Badge } from '@42-central/ui-react/badge';

<Badge color="green">Validated</Badge>
<Badge variant="outline" color="red">Failed</Badge>
<Badge variant="gradient">Pro</Badge>

Playground

Component

Loading preview

Props

Code

<Component variant="light" size="md">
  In progress
</Component>

Full prop browser

Variants

Five shape treatments. Four of them — filled, light, outline, subtle — are the set Button uses; gradient is Badge's own. The default variant is light (badges are usually soft), not filled.

FilledLightOutlineSubtleGradient

Code

<Badge variant="filled">Filled</Badge>
<Badge variant="light">Light</Badge>
<Badge variant="outline">Outline</Badge>
<Badge variant="subtle">Subtle</Badge>
<Badge variant="gradient">Gradient</Badge>

gradient is palette-independent — it ignores color and paints its own linear gradient, which you steer with the gradient prop:

<Badge variant="gradient" gradient={{ from: 'cyan', to: 'blue', dir: 'to-br' }}>Pro</Badge>

Colors

Any color in the palette pairs with any variant (except gradient). Use it for status semantics: green for success, red for failure, orange for in-progress.

brandneutralredorangeyellowgreentealcyanbluepurplepink
brandneutralredorangeyellowgreentealcyanbluepurplepink

Code

<Badge variant="light"  color="green">Validated</Badge>
<Badge variant="light"  color="orange">Pending</Badge>
<Badge variant="filled" color="red">Failed</Badge>
<Badge variant="outline" color="neutral">Queued</Badge>

Sizes

Extra smallSmallMediumLargeExtra large

Code

<Badge size="xs">Extra small</Badge>
<Badge size="sm">Small</Badge>
<Badge size="md">Medium</Badge>
<Badge size="lg">Large</Badge>
<Badge size="xl">Extra large</Badge>

API

Prop

Type

All other props are forwarded to the underlying <span> (or asChild element).

Accessibility

Badge renders a <span>: nothing to focus, nothing to click. If you need an interactive badge (a tag filter, a count that reveals its detail), use asChild with a real <button> so the semantics line up — the kit's focus ring comes with it, so you supply no className for it:

Code

<Badge asChild color="brand">
  <button type="button" onClick={...}>Remove tag</button>
</Badge>

As a hover-card trigger

asChild on both sides collapses HoverCard.Trigger and Badge into a single element that is the badge — one DOM node, keyboard-reachable, with the ring hugging the badge's own radius. This is the idiomatic way to show a compact value that reveals its detail on hover or focus, e.g. a count standing in for a list too long to render inline:

<HoverCard.Root>
  <HoverCard.Trigger asChild>
    <Badge asChild variant="light" aria-label="12 campuses">
      <button type="button">12</button>
    </Badge>
  </HoverCard.Trigger>
  <HoverCard.Content>{/* the full list */}</HoverCard.Content>
</HoverCard.Root>

Give the button an aria-label when the visible text is a bare number — "12" alone doesn't say what it counts.

Changelog

v0.17.0
  • The light variant tints from --c-solid, as in Figma

    #262
v0.9.2
  • Carry the kit's focus ring, so composing one onto a real control with asChild is keyboard-visible

    #142
v0.6.0
  • Scale the icon and spacing with each size

    #103
v0.5.0
  • xs and xl sizes, with sm–lg aligned to the Figma spec

    #59
v0.3.1
  • A Badge with no color gets its neutral background and border back

    #37
v0.3.0
  • Panels and highlights use translucent washes instead of opaque grays

    #35
v0.0.1
  • Badge

On this page