Badge
Tinted pill for status text, counts and dots, optionally pinned to a corner of another element.
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
tone | BadgeTone | neutral | Colour role of the badge. |
count | number | undefined | undefined | Number to display instead of the slotted text. Hidden when it is `0` unless `show-zero` is set. |
max | number | 99 | Upper bound for `count`; larger values render as ` |
show-zero | boolean | false | Keeps a `count` of `0` visible. |
dot | boolean | false | Renders a small dot without text. |
pulse | boolean | false | Animates a fading ring around a `dot` badge to draw attention. |
placement | BadgePlacement | top-right | Corner of the `anchor` element the badge is pinned to. |
overlap | BadgeOverlap | rectangular | Shape of the anchor: `circular` pulls the badge onto the edge of a round anchor instead of its bounding-box corner. |
CSS custom properties
Grouped by the element and state they target. Click a group to collapse it; click a name to copy it.
| Name | Type | Default | Description |
|---|---|---|---|
--c2-badge--height | pixel | 20px | |
--c2-badge--min-width | pixel | 20px | Keeps single digits round. |
--c2-badge--padding-left | padding | 6px | |
--c2-badge--padding-right | padding | 6px | |
--c2-badge--gap | pixel | 4px | Space between the icon and the text. |
--c2-badge--border-radius | border-radius | 999px | |
--c2-badge--border | border | none | Set a border for an outlined look, together with a transparent background. |
--c2-badge--box-shadow | box-shadow | — | |
--c2-badge--background | background | — | Overrides the tone background. |
--c2-badge--color | color | — | Overrides the tone text colour. |
--c2-badge--font-family | font-family | inherit | |
--c2-badge--font-size | font-size | 12px | |
--c2-badge--font-weight | font-weight | 500 | |
--c2-badge--line-height | line-height | 1 | |
--c2-badge--letter-spacing | pixel | — | |
--c2-badge--text-transform | text-transform | none | |
--c2-badge__icon--size | pixel | 12px | |
--c2-badge__neutral--background | background | #f4f4f5 | |
--c2-badge__neutral--color | color | #52525b | |
--c2-badge__primary--background | background | #edf1fe | |
--c2-badge__primary--color | color | #0265dc | |
--c2-badge__success--background | background | #dcfce7 | |
--c2-badge__success--color | color | #166534 | |
--c2-badge__warning--background | background | #fef3c7 | |
--c2-badge__warning--color | color | #92400e | |
--c2-badge__danger--background | background | #fee2e2 | |
--c2-badge__danger--color | color | #dc2626 | |
--c2-badge__info--background | background | #e0f2fe | |
--c2-badge__info--color | color | #075985 | |
--c2-badge__dot--size | pixel | 8px | Diameter of the `dot` badge; its colour is the tone text colour. |
--c2-badge__pulse--animation-duration | time | 1.5s | Length of one `pulse` cycle; respects reduced motion. |
--c2-badge__anchor--border | border | 2px solid #ffffff | Ring around an anchored badge, in the page background colour. Drawn outside a `dot`. |
--c2-badge__anchor--offset-x | pixel | 0px | Moves an anchored badge inwards horizontally (`14.6%` with `overlap="circular"`). |
--c2-badge__anchor--offset-y | pixel | 0px | Moves an anchored badge inwards vertically (`14.6%` with `overlap="circular"`). |