Demos

A badge with the default style.

Usage

Use a badge to tag something with a short status, such as "In range" or "New". Keep it to one or two words.

Import it from @workspace/ui/components/badge.

Notes

  • A badge is a span by default. Pass render to make it a link.
  • Mark an icon with data-icon="inline-start" or data-icon="inline-end" so the padding adjusts.
  • Do not rely on colour alone for status. Put the status in the text, too.

Examples

Variants

default, secondary, outline, destructive, ghost, and link.

With icon

Icons before or after the text.

Pass an a through render. Linked badges get a hover style.

Props

Unlisted props pass through to the rendered element.

Badge

PropTypeDefaultDescription
variant"default", "secondary", "outline", "destructive", "ghost", or "link"defaultVisual style.
renderReactElement—Element to render instead of a span, such as <a href="..." />.
classNamestring—Classes merged onto the badge.

badgeVariants is also exported, for giving another element the badge style.