Badges
Small components for indicating status and counts, or labelling items.
The examples use Badge with variant, theme, and pill props to generate the corresponding
Bootstrap styles.
Examples
Badges are tiny, static display components used for adding context to other elements. They can be used as part of navigation, buttons, and more to provide a counter or label. Badges scale to match the size of the immediate parent element by using relative font sizing and em units.
Badges come in three variants: solid (default), subtle, and outline.
<div className="d-flex flex-wrap gap-2 align-items-center">
<Badge theme="primary">
New
</Badge>
<Badge
theme="primary"
variant="subtle"
>
New
</Badge>
<Badge
theme="primary"
variant="outline"
>
New
</Badge>
</div>Headings
Badges adapt to the font-size of the parent element.
Example heading New
Example heading New
Example heading New
Example heading New
Example heading New
Example heading New
<div className="d-flex flex-wrap gap-2 align-items-center">
<h1>
Example heading
<Badge>
New
</Badge>
</h1>
<h2>
Example heading
<Badge>
New
</Badge>
</h2>
<h3>
Example heading
<Badge>
New
</Badge>
</h3>
<h4>
Example heading
<Badge>
New
</Badge>
</h4>
<h5>
Example heading
<Badge>
New
</Badge>
</h5>
<h6>
Example heading
<Badge>
New
</Badge>
</h6>
</div>Buttons
Badges can be used as part of links or buttons to provide a counter.
<div className="d-flex flex-wrap gap-2 align-items-center">
<Button
theme="primary"
variant="solid"
>
Notifications
<Badge theme="danger">
4
</Badge>
</Button>
</div>Note that depending on how they are used, badges may be confusing for users of screen readers and similar assistive technologies. While the styling of badges provides a visual cue as to their purpose, these users will simply be presented with the content of the badge. Depending on the specific situation, these badges may seem like random additional words or numbers at the end of a sentence, link, or button.
Unless the context is clear (as with the “Notifications” example, where it is understood that the “4” is the number of notifications), Include additional context in accessible text when the badge's meaning is not clear.
Positioned
Use Badge for the indicator and pass positioning and spacing utilities through its className.
<div className="d-flex flex-wrap gap-2 align-items-center">
<Button
className="position-relative"
theme="primary"
variant="solid"
>
Inbox
<Badge
className="position-absolute top-0 start-100 translate-middle border border-bg"
pill
theme="danger"
>
99+
<span className="visually-hidden">
unread messages
</span>
</Badge>
</Button>
</div>For a dot indicator without a count, use Badge with appearance utilities in className and
accessible text describing the status.
<div className="d-flex flex-wrap gap-2 align-items-center">
<Button
className="position-relative"
theme="primary"
variant="solid"
>
Profile
<Badge
className="position-absolute top-0 start-100 translate-middle p-2 rounded-circle"
theme="danger"
>
<span className="visually-hidden">
New alerts
</span>
</Badge>
</Button>
</div>Variants
Set theme on Badge to apply a semantic theme color.
<div className="d-flex flex-wrap gap-2 align-items-center">
<Badge theme="primary">
Primary
</Badge>
<Badge theme="accent">
Accent
</Badge>
<Badge theme="secondary">
Secondary
</Badge>
<Badge theme="success">
Success
</Badge>
<Badge theme="danger">
Danger
</Badge>
<Badge theme="warning">
Warning
</Badge>
<Badge theme="info">
Info
</Badge>
<Badge theme="inverse">
Inverse
</Badge>
</div><div className="d-flex flex-wrap gap-2 align-items-center">
<Badge
theme="primary"
variant="subtle"
>
Primary
</Badge>
<Badge
theme="accent"
variant="subtle"
>
Accent
</Badge>
<Badge
theme="secondary"
variant="subtle"
>
Secondary
</Badge>
<Badge
theme="success"
variant="subtle"
>
Success
</Badge>
<Badge
theme="danger"
variant="subtle"
>
Danger
</Badge>
<Badge
theme="warning"
variant="subtle"
>
Warning
</Badge>
<Badge
theme="info"
variant="subtle"
>
Info
</Badge>
<Badge
theme="inverse"
variant="subtle"
>
Inverse
</Badge>
</div><div className="d-flex flex-wrap gap-2 align-items-center">
<Badge
theme="primary"
variant="outline"
>
Primary
</Badge>
<Badge
theme="accent"
variant="outline"
>
Accent
</Badge>
<Badge
theme="secondary"
variant="outline"
>
Secondary
</Badge>
<Badge
theme="success"
variant="outline"
>
Success
</Badge>
<Badge
theme="danger"
variant="outline"
>
Danger
</Badge>
<Badge
theme="warning"
variant="outline"
>
Warning
</Badge>
<Badge
theme="info"
variant="outline"
>
Info
</Badge>
<Badge
theme="inverse"
variant="outline"
>
Inverse
</Badge>
</div>Conveying meaning to assistive technologies: Color provides only a visual indication. Ensure the meaning is also clear from the content or included in accessible text.
CSS
Variables
Customize the component with the following local CSS variables. Override them through the wrapper’s style prop or your own CSS module.
| CSS variable | Default |
|---|---|
--bs-badge-gap | 0.375em |
--bs-badge-padding-x | 0.625em |
--bs-badge-padding-y | 0.25em |
--bs-badge-font-size | clamp(12px, 0.75em, 0.75em) |
--bs-badge-font-weight | var(--bs-font-weight-semibold) |
--bs-badge-color | inherit |
--bs-badge-bg | var(--bs-bg-2) |
--bs-badge-border-width | var(--bs-border-width) |
--bs-badge-border-color | transparent |
--bs-badge-border-radius | var(--bs-radius-7) |