Badges are small, lightweight visual indicators used to label items, highlight statuses (e.g. "New", "Verified", "Beta"), or display numerical counters (such as unread emails or shopping cart counts). In Bootstrap 5, badges scale proportionally to match the font size of their immediate parent element.
Apply .badge paired with a background color class. Use .rounded-pill for stadium-shaped rounded pills:
<!-- Standard Badges -->
<span class="badge bg-primary">Primary</span>
<span class="badge bg-success">Verified</span>
<span class="badge bg-danger">Expired</span>
<span class="badge bg-warning text-dark">Pending</span>
<!-- Rounded Pill Badges -->
<span class="badge rounded-pill bg-info text-dark">Pill Info</span>
<span class="badge rounded-pill bg-dark">Class 25 of 48</span>
Badges inherit font sizes using em units, scaling automatically inside headings:
<h2>Bootstrap Masterclass <span class="badge bg-secondary">New</span></h2>
<!-- Notification Counter on Button -->
<button type="button" class="btn btn-primary">
Notifications <span class="badge text-bg-light">4</span>
</button>
Create modern smartphone-style notification dots positioned at the top-right corner of an action button:
<button type="button" class="btn btn-primary position-relative">
<i class="fa fa-envelope"></i> Inbox
<span class="position-absolute top-0 start-100 translate-middle badge rounded-pill bg-danger">
99+
<span class="visually-hidden">unread messages</span>
</span>
</button>
Strengthen your responsive web design mastery by studying these connected classes:
Embed pill badges inside buttons to show unread message counts.
Display item counts next to list items using flexbox auto margins.
Use matching colors between alert boxes and highlighted badges.
Scale badges automatically to match the font size of parent headings.
.p-2 and .border.border-light to an empty <span class='position-absolute top-0 start-100 translate-middle p-2 bg-danger border border-light rounded-circle'></span>.
<a href='#' class='badge bg-primary text-decoration-none'>React</a>.
Advance your practical frontend engineering skills with the next topic in our synchronized curriculum.
Continue to Class 26: Progress Bars → Previous: ← Class 24: Alerts & Notifications | Full Syllabus