网页
综合
更新时间 2026-11-14 01:33:55
Badges · Bootstrap v6.0
自动蜘蛛
getbootstrap.com
正文约 2019 字
Small components for indicating status and counts, or labelling items.
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.
Badges adapt to the font-size of the parent element.
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.
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.
Use the contextual .theme-{color} classes to apply a semantic theme color to badges.
Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies like screen readers. Please ensure the meaning is obvious from the content itself (e.g., the visible text with a sufficient color contrast) or is included through alternative means, such as additional text hidden with the .visually-hidden class.
Badges use local CSS variables on .badge for real-time customization. Values for the CSS variables are generated from Sass maps unique to each component and applied to the aforementioned class.
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。