Alerts
Alerts show feedback messages.
<div class="alert alert-success">Saved successfully!</div>
- Colours:
alert-primary,alert-success,alert-danger,alert-warning,alert-info… - Links inside:
alert-linkmatches the alert colour - Headings:
alert-heading - Dismissible: add
alert-dismissible fade showand a close button<button class="btn-close" data-bs-dismiss="alert">(needs Bootstrap JS)
Badges
Small labels and counters.
badge text-bg-primary— coloured labelrounded-pill— pill shape- Inside buttons:
Messages <span class="badge text-bg-light">4</span> - Notification dot:
position-absolute top-0 start-100 translate-middle
Example
Example — Alerts and badges
HTML
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<div class="container my-3">
<div class="alert alert-success"><strong>Success!</strong> Your profile was updated.</div>
<div class="alert alert-danger">Payment failed. <a href="#" class="alert-link">Try again</a>.</div>
<div class="alert alert-warning alert-dismissible fade show">
Your exam starts in 10 minutes.
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<h4>New course <span class="badge text-bg-danger">Hot</span></h4>
<span class="badge rounded-pill text-bg-primary">HTML</span>
<span class="badge rounded-pill text-bg-info">CSS</span>
<button class="btn btn-primary position-relative ms-3">
Inbox
<span class="position-absolute top-0 start-100 translate-middle badge rounded-pill bg-danger">9</span>
</button>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>