Badge
Label status or metadata beside related content.
Anatomy#
Usage#
Use Badge for compact status or metadata beside content. It renders a presentational span by default.
For an action, render a semantic interactive element with an accessible name.
Presentational status#
Place Badge beside a separately labeled control or heading. It does not replace an accessible status
announcement where one is required. variant (solid, soft by default, subtle, outline),
tone, and size (sm, md by default, lg) change appearance only.
Label and icons#
Pass label instead of children when the text comes from data. label takes precedence over
children when both are set. leading and trailing take icon names and render before and after
the label. A badge with no label and exactly one icon renders as a square icon badge.
Interactive root#
For a clickable badge, set as to a semantic element and pass the attributes that element requires.
Examples#
Label task status in a queue#
Keep the task title as the accessible name. Badge only restates workflow state.
Annotate a deployment and commit metadata#
Use leading or trailing icons when the label names a pipeline stage or a git fact.
Filter an issue list#
Render Badge as a button when the chip is a command. Keep type="button" and an onClick handler;
the visible label is the accessible name.
API Reference#
Props#
Props for the Badge component. Renders a <span> element by default.