agyanadda@gmail.com

Bootstrap Colors

Content and Utilities 1 min read Updated Dec 1, 2026 Topic 7 of 32

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-subtle with text-success-emphasis
  • Auto readable text: text-bg-warning sets 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>

Test Yourself With Exercises

Exercise 1 Multiple Choice

Which colour name is used for errors?

Exercise 2 True / False

text-bg-warning sets both the background and a readable text colour.

Exercise 3 Fill in the Blank

Add data-bs-theme="___" to switch an element to dark mode.

Frequently Asked Questions

Quick way: override --bs-primary and --bs-primary-rgb in your CSS. Full way: change $primary in Bootstrap's Sass source and rebuild.