Summit
ComponentsDisplay

Badge

A Badge shows users the status, a count, or a category of a record.

When to Use

  • for the status of a record in a Table or a list, such as “Paid” or “Overdue”
  • for a column of statuses, with dot
  • for a short figure next to a title, like the change of “12.5%” on a dashboard Card
  • for work in progress on one record, like “Syncing”, with a Spinner

When Not to Use

  • for a message with a title and a description (use an Alert)
  • for an action (use a Button)
  • for the count on a Sidebar item (use SidebarMenuBadge in Sidebar)
  • for the mark on the corner of an Avatar (use AvatarBadge in Avatar)

Anatomy

Paid
Paid
ElementUsage
LabelRequired
ContainerRequired
IconOptional
DotOptional

Variants

VariantPurpose
defaultThe one label in a view that needs the most emphasis
secondaryA status that is neither good nor bad, such as “Sent” or “Draft”
outlineA category or a count
ghostA label within a line of text
linkA Badge rendered as a link that should look like one
destructiveAn error or a loss, such as “Overdue”
successA good outcome, such as “Paid”
warningA state that needs attention, such as “Awaiting payment”

See Color for the three status colors.

Dot

When dot is set, the fill is replaced by a marker in the variant’s color. The marker leads each label, so users can scan a column of statuses from top to bottom.

The variant changes only the color, so the label must state the status: color can’t be the only sign of it, as WCAG 2.2 SC 1.4.1 Use of Color requires.

DoName the status in the label.
Don’tWhen color alone communicates the status, users who can’t tell green from red will see three identical dots, and screen reader users will hear nothing.

Behavior

A Badge is as wide as its label. The label doesn’t wrap, and the Badge doesn’t shrink in a flex row, so a label that is wider than its container will overflow it. Nothing happens when users click a Badge unless it is rendered as a link.

Content

StringRuleExampleCounterexample
LabelUse sentence case“Awaiting payment”“Awaiting Payment”
LabelState the status itself, in one or two words“Overdue”“This invoice is overdue”

Accessibility

A Badge isn’t focusable and has no keys. When it is rendered as an a with an href, it is a link in the tab order. A Badge isn’t a live region, so a status that changes while the page is open isn’t announced.

Requirements

The label must state the status in words so that users who can’t tell the colors apart can read it. The variant sets only a color, and WCAG 2.2 SC 1.4.1 Use of Color doesn’t allow color to be the only sign of a status.

Set aria-hidden on an icon in a Badge. See Iconography for the rule.

Installation

npx shadcn@latest add @summit/badge

Usage

import { Badge } from '@/components/ui/badge';

<Badge variant="secondary">Draft</Badge>;

Show a Status

To show a status, set the variant that matches it, and set dot for the marker.

Show a Status
<Badge variant="destructive" dot>
    Overdue
</Badge>

With an Icon

To place an icon before or after the label, mark it with data-icon="inline-start" or data-icon="inline-end".

With an Icon
import { CheckIcon } from '@phosphor-icons/react';

<Badge variant="success">
    <CheckIcon aria-hidden data-icon="inline-start" />
    Paid
</Badge>;

To render a Badge as a link, pass an a to render, which replaces the span.

As a Link
<Badge variant="outline" render={<a href="/invoices?status=overdue" />}>
    2 overdue
</Badge>

API Reference

PropTypeDefaultDescription
variant'default' | 'secondary' | 'destructive' | 'success' | 'warning' | 'outline' | 'ghost' | 'link''default'The fill and the text color
dotbooleanfalseShows a marker before the label and removes the fill
renderAn element or a function that returns oneNoneThe element to render in place of the span

Other props are passed to the element. See the Base UI useRender documentation for render.

On this page