Badge
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.
Idea React provides the Badge wrapper for these examples.
Badges come in three variants: solid (default), subtle, and outline.
Examples
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
Buttons
Badges can be used as part of links or buttons to provide a counter.
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), consider including additional context with a visually hidden piece of additional text.
Positioned
Use utilities to modify a .badge and position it in the corner of a link or button.
You can also replace the .badge class with a few more utilities without a count for a more generic
indicator.
Variants
Use the contextual .theme-{color} classes to apply a semantic theme color to badges.
The theme colors above are the same contextual colors used across Bootstrap and Idea React. Make sure text and background contrast is sufficient when choosing a theme.
CSS
Badge colors, padding, and border radius are driven by Bootstrap's badge CSS variables and Sass maps. See the upstream badge CSS for the variable reference.