Utilities
Background
Background colour utilities for all eleven theme colours, the body surfaces, subtle tints and opacity.
Background color
.bg-* sets background-color only. It does not pick a text colour for you — if the
background is dark, add a text utility, or use the
.text-bg-* helper which does both. The swatches below use
.p-3.mb-2 so the dotted preview shows where each box ends.
HTML
<div class="p-3 mb-2 bg-primary text-dark rounded-1">.bg-primary — gold-700, gold-500 in dark mode</div>
<div class="p-3 mb-2 bg-secondary text-white rounded-1">.bg-secondary — navy-300</div>
<div class="p-3 mb-2 bg-success text-light rounded-1">.bg-success — green-600</div>
<div class="p-3 mb-2 bg-info text-light rounded-1">.bg-info — navy-500</div>
<div class="p-3 mb-2 bg-warning text-dark rounded-1">.bg-warning — gold-300</div>
<div class="p-3 mb-2 bg-danger text-light rounded-1">.bg-danger — red-600</div>
<div class="p-3 mb-2 bg-light text-dark rounded-1">.bg-light — cream-50</div>
<div class="p-3 mb-2 bg-dark text-light rounded-1">.bg-dark — navy-900</div>
<div class="p-3 mb-2 bg-gold text-dark rounded-1">.bg-gold — gold-500</div>
<div class="p-3 mb-2 bg-navy text-light rounded-1">.bg-navy — navy-700</div>
<div class="p-3 mb-2 bg-cream text-dark rounded-1">.bg-cream — cream-100</div>
<div class="p-3 mb-2 bg-black text-white rounded-1">.bg-black</div>
<div class="p-3 mb-2 bg-white text-dark rounded-1">.bg-white</div>
<div class="p-3 bg-transparent text-body rounded-1">.bg-transparent</div>.bg-primary changes between modes. .bg-gold is always gold-500 and
.bg-navy always navy-700; use them when a surface must not flip with the colour scheme.Body surfaces
Three utilities follow the page's own surface variables and therefore adapt to colour mode. They are the right choice for panels, wells and sidebars.
HTML
<div class="p-3 mb-2 bg-body text-body rounded-1 border">.bg-body — cream-100 / navy-900</div>
<div class="p-3 mb-2 bg-body-secondary text-body rounded-1 border">.bg-body-secondary — cream-300 / #0e2048</div>
<div class="p-3 bg-body-tertiary text-body rounded-1 border">.bg-body-tertiary — cream-50 / navy-700</div>Subtle backgrounds
.bg-*-subtle is a tint of the colour that stays light in light mode and dark in dark mode.
Pair it with the matching .text-*-emphasis and .border-*-subtle, exactly as
alerts do.
HTML
<div class="p-3 mb-2 bg-primary-subtle text-primary-emphasis border border-primary-subtle rounded-1">.bg-primary-subtle</div>
<div class="p-3 mb-2 bg-secondary-subtle text-secondary-emphasis border border-secondary-subtle rounded-1">.bg-secondary-subtle</div>
<div class="p-3 mb-2 bg-success-subtle text-success-emphasis border border-success-subtle rounded-1">.bg-success-subtle</div>
<div class="p-3 mb-2 bg-info-subtle text-info-emphasis border border-info-subtle rounded-1">.bg-info-subtle</div>
<div class="p-3 mb-2 bg-warning-subtle text-warning-emphasis border border-warning-subtle rounded-1">.bg-warning-subtle</div>
<div class="p-3 mb-2 bg-danger-subtle text-danger-emphasis border border-danger-subtle rounded-1">.bg-danger-subtle</div>
<div class="p-3 mb-2 bg-light-subtle text-light-emphasis border border-light-subtle rounded-1">.bg-light-subtle</div>
<div class="p-3 bg-dark-subtle text-dark-emphasis border border-dark-subtle rounded-1">.bg-dark-subtle</div>--bs-gold-bg-subtle, --bs-navy-bg-subtle,
--bs-cream-bg-subtle, and their -border-subtle / -text-emphasis
partners) but no .bg-gold-subtle class is generated. Use the variable directly.HTML
<div class="p-3 rounded-1 border" style="background-color: var(--bs-gold-bg-subtle); color: var(--bs-gold-text-emphasis); border-color: var(--bs-gold-border-subtle) !important">Gold subtle, via custom properties</div>Opacity
Each .bg-* rule sets --bs-bg-opacity: 1 and reads it back through
rgba(var(--bs-*-rgb), var(--bs-bg-opacity)). Override the variable with
.bg-opacity-* or inline.
HTML
<div class="bg-navy p-3 mb-2 text-light rounded-1">This is default navy background</div>
<div class="bg-navy p-3 mb-2 text-light rounded-1 bg-opacity-75">This is 75% opacity navy background</div>
<div class="bg-navy p-3 mb-2 text-dark rounded-1 bg-opacity-50">This is 50% opacity navy background</div>
<div class="bg-navy p-3 mb-2 text-dark rounded-1 bg-opacity-25">This is 25% opacity navy background</div>
<div class="bg-navy p-3 text-dark rounded-1 bg-opacity-10">This is 10% opacity navy background</div><div class="bg-gold p-3" style="--bs-bg-opacity: .6">Gold at 60%</div>
The body surfaces and .bg-black/.bg-white take the same opacity utilities. Subtle backgrounds do not; they are plain hex values.
Background gradient
The theme sets $enable-gradients: false, so buttons, progress bars and navbars are flat. The
.bg-gradient utility still compiles: it layers --bs-gradient, a white
15 % → 0 % top-to-bottom wash, over whatever background colour is set. Use it sparingly; the brand's
preferred shine is .bg-gold-ramp.
HTML
<div class="p-3 mb-2 bg-navy bg-gradient text-light rounded-1">.bg-navy.bg-gradient</div>
<div class="p-3 bg-gold-ramp rounded-1">.bg-gold-ramp — gold-300 → gold-500 → gold-700, navy text</div>:root { --bs-gradient: linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0)); }
.bg-gradient { background-image: var(--bs-gradient) !important; }
CSS
Each rule is two lines: a local opacity variable and the colour.
.bg-gold {
--bs-bg-opacity: 1;
background-color: rgba(var(--bs-gold-rgb), var(--bs-bg-opacity)) !important;
}
.bg-body-tertiary {
--bs-bg-opacity: 1;
background-color: rgba(var(--bs-tertiary-bg-rgb), var(--bs-bg-opacity)) !important;
}
The -rgb variables are listed in CSS variables.
Sass
The values come from $utilities-bg-colors, built in Bootstrap's _maps.scss from $theme-colors-rgb plus the body surfaces. The theme feeds it through $theme-colors:
// scss/_maps.scss
$rb-theme-colors: (
"gold": $rb-gold-500,
"navy": $rb-navy-700,
"cream": $rb-cream-100,
);
$theme-colors: map-merge($theme-colors, $rb-theme-colors);
And the generator entry, from Bootstrap's _utilities.scss:
"background-color": (
property: background-color,
class: bg,
local-vars: (
"bg-opacity": 1
),
values: map-merge(
$utilities-bg-colors,
(
"transparent": transparent,
"body-secondary": rgba(var(--#{$prefix}secondary-bg-rgb), var(--#{$prefix}bg-opacity)),
"body-tertiary": rgba(var(--#{$prefix}tertiary-bg-rgb), var(--#{$prefix}bg-opacity)),
)
)
),
"subtle-background-color": (
property: background-color,
class: bg,
values: $utilities-bg-subtle
),
See the utility API for how to add, change or remove values.