layout | title | description | group | aliases | toc | bootstrap | other_frameworks | |||
---|---|---|---|---|---|---|---|---|---|---|
docs |
Badges |
Bootstrap badge is small count and labeling components. |
components |
|
true |
true |
badge |
Bootstrap badge scale to suit the size of the parent element by using relative font sizing and em
units.
{{< example >}}
{{< /example >}}Badges can be used as part of links or buttons to provide a counter.
{{< example >}} Notifications 4 {{< /example >}}
Remark that depending on how you use them, badges may be complicated for users of screen readers and related assistive technologies.
Unless the context is clear, 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.
{{< example >}} Inbox 99+ unread messages {{< /example >}}
You can also replace the .badge
class with a few more utilities without a count for a more generic indicator.
{{< example >}} Profile New alerts {{< /example >}}
Add any of the below-mentioned classes to modify the presentation of a badge. Please note that when using CoreUI for Bootstrap's default .bg-light
, you'll likely need a text color utility like .text-dark
for proper styling. This is because background utilities do not set anything but background-color
.
{{< example >}} {{< badge.inline >}} {{- range (index $.Site.Data "theme-colors") }} {{ .name | title }}{{- end -}} {{< /badge.inline >}} {{< /example >}}
{{< callout info >}} {{< partial "callouts/warning-color-assistive-technologies.md" >}} {{< /callout >}}
Apply the .rounded-pill
modifier class to make badges rounded.
{{< example >}} {{< badge.inline >}} {{- range (index $.Site.Data "theme-colors") }} {{ .name | title }}{{- end -}} {{< /badge.inline >}} {{< /example >}}
Badges use local CSS variables on .badge
for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
{{< scss-docs name="badge-css-vars" file="scss/_badge.scss" >}}
{{< scss-docs name="badge-variables" file="scss/_variables.scss" >}}