
Bs5 Colors in Bootstrap
In Bootstrap 5 (BS5), the color system provides a wide range of utility classes for text, backgrounds, borders, and more. These classes are based on Bootstrap’s theme color palette and make it easy to apply consistent styles across your UI.
? Theme Colors
These are the standard Bootstrap 5 color names:
Class Name | Color Use Example |
---|---|
primary | Main action (#0d6efd ) |
secondary | Secondary actions (#6c757d ) |
success | Success messages (#198754 ) |
danger | Errors or warnings (#dc3545 ) |
warning | Caution (#ffc107 ) |
info | Information (#0dcaf0 ) |
light | Light background (#f8f9fa ) |
dark | Dark theme (#212529 ) |
?? Text Color Classes
<p class="text-primary">Primary text</p><p class="text-danger">Danger text</p>
Classes:
text-primary
,text-secondary
,text-success
,text-danger
, etc.text-white
,text-black
,text-muted
text-reset
: Resets inherited text colortext-body
: Default body text color
? Background Color Classes
<div class="bg-warning text-dark p-3">Warning background</div>
Classes:
bg-primary
,bg-success
,bg-danger
, etc.Combine with
text-*
to control readability (e.g.,text-light
ortext-dark
)
? Border Color Classes
<div class="border border-success p-2">Success border</div>
Use:
border
border-[color]
(e.g.,border-danger
,border-info
)
? Opacity and Emphasis Utilities
<p class="text-primary text-opacity-75">75% opaque primary text</p><div class="bg-success bg-opacity-50">50% opaque background</div>
Classes:
text-opacity-[0–100]
bg-opacity-[0–100]
?? Utility Overview
Purpose | Classes Example |
---|---|
Text Color | text-primary , text-muted |
Background | bg-danger , bg-light |
Borders | border , border-warning |
Opacity | text-opacity-50 , bg-opacity-25 |
Would you like a custom theme color example, or info on how to extend colors using SCSS?