Bootstrap has a set of theme colours with meaning.
| Name | Typical use |
|---|---|
primary |
main brand action (blue) |
secondary |
less important (grey) |
success |
done, saved (green) |
danger |
error, delete (red) |
warning |
caution (yellow) |
info |
information (cyan) |
light / dark |
light and dark backgrounds |
Text and background
- Text:
text-primary,text-danger,text-muted,text-white - Background:
bg-primary,bg-light,bg-dark - Soft background:
bg-success-subtlewithtext-success-emphasis - Auto readable text:
text-bg-warningsets background and a matching text colour
Opacity
bg-primary bg-opacity-25, text-dark text-opacity-50
Dark mode
Add data-bs-theme="dark" to <html> or any element.
Example
Example — Theme colours
HTML
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<div class="container my-3">
<p class="text-primary">text-primary</p>
<p class="text-danger">text-danger</p>
<div class="p-2 mb-2 text-bg-success">text-bg-success</div>
<div class="p-2 mb-2 text-bg-warning">text-bg-warning</div>
<div class="p-2 mb-2 bg-info-subtle text-info-emphasis border border-info-subtle rounded">Subtle info box</div>
<div class="p-2 mb-2 bg-primary bg-opacity-25">bg-primary with 25% opacity</div>
<div class="p-3 rounded" data-bs-theme="dark" style="background: var(--bs-body-bg); color: var(--bs-body-color);">Dark mode section</div>
</div>