Skip to content

Latest commit

 

History

History
105 lines (78 loc) · 3.41 KB

badge.md

File metadata and controls

105 lines (78 loc) · 3.41 KB
layout title description group aliases toc bootstrap other_frameworks
docs
Badges
Bootstrap badge is small count and labeling components.
components
/4.0/components/badge/
/4.1/components/badge/
/components/bootstrap/badge/
true
true
badge

Examples

Bootstrap badge scale to suit the size of the parent element by using relative font sizing and em units.

Headings

{{< example >}}

Example heading New

Example heading New

Example heading New

Example heading New

Example heading New
Example heading New
{{< /example >}}

Buttons

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.

Positioned

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 >}}

Contextual variations

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 >}}

Pill badges

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 >}}

Customizing

CSS variables

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" >}}

SASS variables

{{< scss-docs name="badge-variables" file="scss/_variables.scss" >}}