Skip to content

    Badge

    A short label for a status or a category. It uses a soft fill, or an outline when it should stay quiet. Its fill is never a solid hue; a solid appears only as the small decorative dot. Solid fills with text-on-<hue> are for Avatar.

    React

    Preview

    Beta

    Props

    • variant
    • size
    • dot
    • ring
    • label
    • icon
    import { Badge } from "@/components/ui/badge"
    
    <Badge>Beta</Badge>

    Usage

    When to use

    • Show the state of an item next to it: Failed, Ready, Expiring.
    • Tag an item with a category the user reads but doesn't act on: Design, Beta.

    When not to use

    • Anything clickable or toggleable. Use Button.
    • A picked value the user can take out, such as an active filter. Use Token with a remove button.
    • Naming a design token or another machine value. Use Token.
    • Sentences or long labels. Keep a badge label short: Beta, Failed, New.

    Platform support

    What each platform has, from the spec. A selected platform is highlighted.

    NameWebiOSAndroidNote
    variantYesYesYes
    sizeYesYesYes
    dotYesYesYes
    ringYesYesYes
    accessibilityLabelNoYesYesOnly on iOS, Android.

    Variants

    variant

    default is a neutral gray label. accent uses the muted accent. outline has no fill, only a thin border. destructive, success, warning and info show a status. red, orange, yellow, green, teal, blue, purple and pink mark a category. Every filled variant pairs the soft background with its matching text color; the fill is never the solid (the dot is the only solid).

    • Beta

      defaultdefault

    • Beta

      accent

    • Beta

      outline

    • Beta

      destructive

    • Beta

      success

    • Beta

      warning

    • Beta

      info

    • Beta

      red

    • Beta

      orange

    • Beta

      yellow

    • Beta

      green

    • Beta

      teal

    • Beta

      blue

    • Beta

      purple

    • Beta

      pink

    import { Badge } from "@/components/ui/badge"
    
    <Badge>Beta</Badge>
    <Badge variant="accent">Beta</Badge>
    <Badge variant="outline">Beta</Badge>
    <Badge variant="destructive">Beta</Badge>
    <Badge variant="success">Beta</Badge>
    <Badge variant="warning">Beta</Badge>
    <Badge variant="info">Beta</Badge>
    <Badge variant="red">Beta</Badge>
    <Badge variant="orange">Beta</Badge>
    <Badge variant="yellow">Beta</Badge>
    <Badge variant="green">Beta</Badge>
    <Badge variant="teal">Beta</Badge>
    <Badge variant="blue">Beta</Badge>
    <Badge variant="purple">Beta</Badge>
    <Badge variant="pink">Beta</Badge>

    size

    md is 24px tall. sm is 20px with tighter padding, like Token, for dense tables and counts inside a tab.

    • Beta

      sm

    • Beta

      mddefault

    import { Badge } from "@/components/ui/badge"
    
    <Badge size="sm">Beta</Badge>
    <Badge>Beta</Badge>

    Examples

    Default

    Beta
    import { Badge } from "@/components/ui/badge"
    
    <Badge>Beta</Badge>

    With icon

    Ready
    import { IconCheck } from "@tabler/icons-react"
    import { Badge } from "@/components/ui/badge"
    
    <Badge variant="success">
      <IconCheck size={12} />
      Ready
    </Badge>

    Info

    Scheduled
    import { Badge } from "@/components/ui/badge"
    
    <Badge variant="info">Scheduled</Badge>

    Status dot

    OnlineFailed
    import { Badge } from "@/components/ui/badge"
    
    <div className="flex items-center gap-sm">
      <Badge variant="success" dot>Online</Badge>
      <Badge variant="destructive" dot>Failed</Badge>
    </div>

    Small

    New
    import { Badge } from "@/components/ui/badge"
    
    <Badge size="sm">New</Badge>

    Dot only

    import { IconMail } from "@tabler/icons-react"
    import { Badge } from "@/components/ui/badge"
    
    <div className="flex items-center gap-md">
      <Badge variant="destructive" dot aria-label="New messages" />
      <span className="relative inline-flex">
        <IconMail size={20} aria-hidden="true" />
        <Badge variant="destructive" dot ring aria-label="New mail" className="absolute end-0 top-0" />
      </span>
    </div>

    Do and don't

    Do

    • Use the status variants (destructive, success, warning, info) for state, and hues for categories.
    • Keep labels short: Beta, Failed, New.
    • Show at most one status badge per row or card.
    • Put the icon (12px) before the label.
    • Use outline for a quiet neutral label next to filled badges.
    • Use a dot-only badge for a notification dot on an icon, named with aria-label, and add ring when it sits on an icon or a photo.

    Don't

    • Don't make a badge clickable.
    • Don't use Badge for filter chips or removable tags. Anything that toggles or has a remove action is a Button.
    • Don't put text or icons on a hue solid (bg-red). Solids are for dots and charts.
    • Don't use the danger solid with text-on-danger for a badge; destructive is the soft pair.
    • Don't restyle colors through className. Pick a variant. If none fits, open an issue instead of overriding it.

    Props

    NameTypeValuesDefaultDescription
    variantenumdefault | accent | outline | destructive | success | warning | info | red | orange | yellow | green | teal | blue | purple | pinkdefaultdefault is a neutral gray label. accent uses the muted accent. outline has no fill, only a thin border. destructive, success, warning and info show a status. red, orange, yellow, green, teal, blue, purple and pink mark a category. Every filled variant pairs the soft background with its matching text color; the fill is never the solid (the dot is the only solid).
    sizeenumsm | mdmdmd is 24px tall. sm is 20px with tighter padding, like Token, for dense tables and counts inside a tab.
    dotboolean-falseA 6px status dot before the label, on the solid of the badge's hue (bg-danger for destructive, bg-<hue> for a hue). The only solid in a badge. Decorative: the label still carries the meaning. With no label the badge is the dot alone, with no pill: name it with aria-label (accessibilityLabel on native), for example a notification dot on an icon.
    ringboolean-falseDot-only badge: adds a spacing-2xs ring in the page color around the dot, so it reads on an icon or any surface. Ignored when the badge has a label.
    accessibilityLabelstring--The name VoiceOver and TalkBack read for a dot-only badge, such as New messages. Required by the dot-only form, as aria-label is what names it on the web. Only on iOS, Android.

    Slots

    NameRequiredDescription
    labelyesShort label, sentence case or a single status word. Leave it out only with dot, for a dot-only badge.
    iconnoOptional leading icon.

    Anatomy

    PartDescription
    rootThe badge surface: size-inline-md (24px) tall, size-inline-sm (20px) for size sm, soft fill, radius-element, compact type.
    iconOptional Tabler icon before the label, 12px.
    dotOptional status dot, data-slot badge-dot, aria-hidden. A circle of spacing-2xs * 3 (6px) on the solid of the badge hue; the only solid in a badge. There is no size token for it, so the size is an expression. With dot and no label the dot is the whole badge: no pill, padding or height.
    ringDot-only badge with ring: a spacing-2xs ring in color-background-page around the dot (on the web the --ring-offset-color AvatarStack uses, the page by default), so the dot reads on an icon, a photo or any surface.

    Accessibility

    Role: generic

    • Badge is not interactive. Don't make it a link or button; put the action on the row or card instead.
    • Color is not the only cue: keep a short text label (Failed, not only a red dot).
    • A dot-only badge (dot with no label) is named by aria-label and then has role="img"; on iOS and Android the dot-only form requires accessibilityLabel. Without aria-label on the web it is aria-hidden, for a parent that names it (BottomNavItem names its dot through dotLabel).
    • Root is a plain span with no role, so a badge is never a live region by default. If a badge's text changes and must be announced (a build going from Running to Failed), add role="status" at the call site.

    Install

    npx werewolf-ui add badge

    Run npx werewolf-ui init once in your app before adding components. Init sets up tokens, their CSS import and agent rules. Add installs this component and its dependencies while preserving your theme. See Installation for requirements and the alternative registry setup.