Bootstrap badges are small labels used to display additional information such as status, counts, categories, notifications, or short messages. Badges are commonly used with buttons, headings, navigation menus, cards, and tables.
.badge class together
with a contextual background class such as .text-bg-primary.
A badge is a small visual label that provides additional information about an element.
Example:
<span class="badge text-bg-primary">
New
</span>
New
Badges are useful when you want to show a short piece of information without taking much space.
The .badge class provides the basic styling for a Bootstrap
badge.
<span class="badge text-bg-success">
Success
</span>
Success
The .badge class is normally combined with a contextual
background utility.
Use text-bg-primary to create a primary-colored badge.
<span class="badge text-bg-primary">
Primary
</span>
Primary
Primary badges can be used for general information or highlighted categories.
The text-bg-success class creates a success-style badge.
<span class="badge text-bg-success">
Completed
</span>
Completed
It can be used for statuses such as Completed, Active, Approved, or Paid.
The text-bg-danger class creates a danger-style badge.
<span class="badge text-bg-danger">
Failed
</span>
Failed
Danger badges can be used for errors, failed operations, or important warning statuses.
The text-bg-warning class creates a warning badge.
<span class="badge text-bg-warning">
Pending
</span>
Pending
Warning badges are useful for statuses that require attention.
The text-bg-info class creates an informational badge.
<span class="badge text-bg-info">
Information
</span>
Information
It can be used to identify additional information or categories.
The text-bg-light class creates a light-colored badge.
<span class="badge text-bg-light border">
Light
</span>
Light
A border can help distinguish a light badge from a light background.
The text-bg-dark class creates a dark badge.
<span class="badge text-bg-dark">
Dark
</span>
Dark
Bootstrap provides several contextual background combinations for badges.
<span class="badge text-bg-primary">Primary</span>
<span class="badge text-bg-secondary">Secondary</span>
<span class="badge text-bg-success">Success</span>
<span class="badge text-bg-danger">Danger</span>
<span class="badge text-bg-warning">Warning</span>
<span class="badge text-bg-info">Info</span>
<span class="badge text-bg-dark">Dark</span>
Primary
Secondary
Success
Danger
Warning
Info
Dark
Badges can be placed inside headings to display additional information.
<h3>
Students
<span class="badge text-bg-primary">
25
</span>
</h3>
This is useful for showing counts next to headings.
Badges can be placed inside buttons to show counts or notifications.
<button class="btn btn-primary">
Messages
<span class="badge text-bg-light">
5
</span>
</button>
Badges are commonly used to show notification counts.
<button class="btn btn-dark">
Notifications
<span class="badge text-bg-danger">
8
</span>
</button>
This pattern is commonly used in dashboards and navigation bars.
A badge can be used inside a Bootstrap card to show status.
<div class="card">
<div class="card-body">
<h5>Course Details</h5>
<span class="badge text-bg-success">
Active
</span>
</div>
</div>
Badges are very useful for displaying status values inside tables.
<td>
<span class="badge text-bg-success">
Active
</span>
</td>
| Name | Status |
|---|---|
| Rahul | Active |
| Amit | Pending |
| Ravi | Inactive |
Badges can be placed inside list group items.
<ul class="list-group">
<li class="list-group-item d-flex justify-content-between">
Students
<span class="badge text-bg-primary">
50
</span>
</li>
</ul>
The .rounded-pill utility can be combined with a badge
to create a pill-shaped appearance.
<span class="badge text-bg-primary rounded-pill">
New
</span>
New
Pill badges are useful for short labels and status indicators.
Pill-shaped badges work especially well for notification counts.
<span class="badge text-bg-danger rounded-pill">
99+
</span>
99+
Badges can also be placed inside links.
<a href="#" class="text-decoration-none">
Products
<span class="badge text-bg-primary">
12
</span>
</a>
Products
12
Bootstrap spacing utilities can be used to add space around badges.
<span class="badge text-bg-primary me-2">
HTML
</span>
<span class="badge text-bg-success">
CSS
</span>
HTML
CSS
The me-2 class adds margin on the end side of the first
badge.
Badges can identify categories in an education website.
<span class="badge text-bg-primary">
HTML
</span>
<span class="badge text-bg-success">
CSS
</span>
<span class="badge text-bg-warning">
JavaScript
</span>
<span class="badge text-bg-danger">
Python
</span>
HTML
CSS
JavaScript
Python
Badges can display student status in an education management system.
<span class="badge text-bg-success">
Active
</span>
<span class="badge text-bg-warning">
Pending
</span>
<span class="badge text-bg-danger">
Inactive
</span>
Badges are useful for showing payment status.
| Student | Payment |
|---|---|
| Rahul | Paid |
| Amit | Pending |
| Ravi | Due |
This makes status information easy to scan.
A badge can highlight newly added content.
<h4>
Bootstrap Tutorial
<span class="badge text-bg-success">
New
</span>
</h4>
This pattern is useful for courses, lessons, products, and blog posts.
Badges can be placed inside different heading elements.
The badge automatically fits naturally with its surrounding text.
Badges should provide useful information rather than relying only on color.
Due, Failed, or Inactive.
Avoid using badges unnecessarily.
Badges work best when they provide short, useful information.
Common Bootstrap badge combinations include:
<span class="badge text-bg-primary">Primary</span>
<span class="badge text-bg-success">Success</span>
<span class="badge text-bg-danger">Danger</span>
<span class="badge text-bg-warning">Warning</span>
<span class="badge text-bg-info">Info</span>
<span class="badge text-bg-dark">Dark</span>
<span class="badge text-bg-primary rounded-pill">
Pill
</span>
Here is an example of badges used in a simple dashboard.
<div class="card">
<div class="card-body">
<h5>Student Dashboard</h5>
<p>
Account Status:
<span class="badge text-bg-success">
Active
</span>
</p>
<p>
Assignments:
<span class="badge text-bg-primary">
12
</span>
</p>
<p>
Pending Fees:
<span class="badge text-bg-danger">
Due
</span>
</p>
</div>
</div>
Account Status: Active
Assignments: 12
Pending Fees: Due
The following example combines headings, badges, counts, status labels, and pill badges.
<div class="container mt-4">
<h3>
Student Management
<span class="badge text-bg-primary rounded-pill">
25
</span>
</h3>
<p>
Active Students:
<span class="badge text-bg-success">
20
</span>
</p>
<p>
Pending Students:
<span class="badge text-bg-warning">
3
</span>
</p>
<p>
Inactive Students:
<span class="badge text-bg-danger">
2
</span>
</p>
</div>
Active Students: 20
Pending Students: 3
Inactive Students: 2
.badge to create a Bootstrap badge.text-bg-primary, text-bg-success, and other contextual classes for badge colors.rounded-pill for pill-shaped badges.Question: Which Bootstrap class is used as the basic class for creating a badge?