Utilities
Colors
Text colour utilities for all eleven theme colours, the emphasis and body variants, and which gold is actually readable.
Colors
.text-* sets color from the theme's --bs-*-rgb variables. Eleven
theme colours, plus black and white. .text-primary follows the dark-mode swap
(gold-700 → gold-500). .text-secondary, .text-info, .text-success
and .text-danger lift to a lighter tint in dark mode so they stay readable on navy; the
matching .link-*, .border-* and .btn-outline-* lift with them. The
rest are fixed.
.text-primary — gold-700 / gold-500
.text-primary-emphasis — #6b5410 / gold-300
.text-secondary — navy-400 / #7c93c2
.text-secondary-emphasis — navy-700 / navy-100
.text-success — green-600 / #55a45d
.text-success-emphasis
.text-info — navy-500
.text-info-emphasis
.text-warning — gold-300
.text-warning-emphasis
.text-danger — red-600
.text-danger-emphasis
.text-light — cream-50
.text-light-emphasis
.text-dark — navy-900
.text-dark-emphasis
.text-gold — gold-500
.text-navy — navy-700
.text-cream — cream-100
.text-black
.text-white
.text-body — navy-900 / cream-100
.text-body-emphasis — black / cream-50
.text-body-secondary — navy-400 / navy-100
.text-body-tertiary — body colour at 50%
.text-black-50 (deprecated)
.text-white-50 (deprecated)
.text-muted (deprecated — use .text-body-secondary)
HTML
<p class="text-primary">.text-primary — gold-700 / gold-500</p>
<p class="text-primary-emphasis">.text-primary-emphasis — #6b5410 / gold-300</p>
<p class="text-secondary">.text-secondary — navy-400 / #7c93c2</p>
<p class="text-secondary-emphasis">.text-secondary-emphasis — navy-700 / navy-100</p>
<p class="text-success">.text-success — green-600 / #55a45d</p>
<p class="text-success-emphasis">.text-success-emphasis</p>
<p class="text-info">.text-info — navy-500</p>
<p class="text-info-emphasis">.text-info-emphasis</p>
<p class="text-warning">.text-warning — gold-300</p>
<p class="text-warning-emphasis">.text-warning-emphasis</p>
<p class="text-danger">.text-danger — red-600</p>
<p class="text-danger-emphasis">.text-danger-emphasis</p>
<p class="text-light bg-dark p-1 rounded-1">.text-light — cream-50</p>
<p class="text-light-emphasis">.text-light-emphasis</p>
<p class="text-dark">.text-dark — navy-900</p>
<p class="text-dark-emphasis">.text-dark-emphasis</p>
<p class="text-gold">.text-gold — gold-500</p>
<p class="text-navy">.text-navy — navy-700</p>
<p class="text-cream bg-navy p-1 rounded-1">.text-cream — cream-100</p>
<p class="text-black">.text-black</p>
<p class="text-white bg-dark p-1 rounded-1">.text-white</p>
<p class="text-body">.text-body — navy-900 / cream-100</p>
<p class="text-body-emphasis">.text-body-emphasis — black / cream-50</p>
<p class="text-body-secondary">.text-body-secondary — navy-400 / navy-100</p>
<p class="text-body-tertiary">.text-body-tertiary — body colour at 50%</p>
<p class="text-black-50 bg-white p-1 rounded-1">.text-black-50 (deprecated)</p>
<p class="text-white-50 bg-dark p-1 rounded-1">.text-white-50 (deprecated)</p>
<p class="text-muted mb-0">.text-muted (deprecated — use .text-body-secondary)</p>.text-dark, .text-navy,
.text-info and .text-black all but vanish on the navy-900 page, and
.text-light, .text-cream and .text-white do the same on cream in light
mode. For text that must read in both modes use .text-body, .text-body-secondary
or a -emphasis variant; reserve the fixed colours for surfaces whose background is also fixed,
such as .bg-navy.Which gold to use
.text-primary (gold-700
#b8941f on cream-100 #f4ecd8) is roughly 2.4:1. .text-gold
(gold-500) is about 1.8:1 and .text-warning (gold-300) is lower still. None of them pass
WCAG AA for text. Use .text-primary-emphasis (#6b5410, about 6:1) for readable
gold-toned text (links and .btn-outline-primary labels already use the text-safe gold-800
#7e620d, about 4.9:1), and keep .text-primary and .text-gold for large display type,
icons, rules and surfaces that sit on navy.This is .text-primary on the page. Decorative at best.
This is .text-primary-emphasis. Read this one.
.text-gold at display size
.text-gold on navy — about 7:1, fine.
.text-primary on navy — also fine in both modes.
HTML
<p class="text-primary">This is .text-primary on the page. Decorative at best.</p>
<p class="text-primary-emphasis">This is .text-primary-emphasis. Read this one.</p>
<p class="text-gold font-display fs-1 text-uppercase mb-2">.text-gold at display size</p>
<div class="text-bg-navy p-3 rounded-1">
<p class="text-gold mb-1">.text-gold on navy — about 7:1, fine.</p>
<p class="text-primary mb-0">.text-primary on navy — also fine in both modes.</p>
</div>
The same logic applies to the -emphasis variants of every colour: they are the version tuned
for body text on the page background in each mode. .text-secondary-emphasis
(navy-700) is the stronger choice; .text-secondary (navy-400, about 5:1) clears AA for small text.
.text-gold-emphasis, .text-navy-emphasis and .text-cream-emphasis
are not generated, although the variables --bs-gold-text-emphasis
(#6b5410 / gold-300), --bs-navy-text-emphasis (navy-900 / navy-100) and
--bs-cream-text-emphasis (navy-700 / cream-50) are. For gold the answer is simply
.text-primary-emphasis, which has the same light value and gold-300 in dark mode. For navy and
cream set the variable inline or in your own rule.<p style="color: var(--bs-navy-text-emphasis)">Navy emphasis via the variable</p>
Opacity
The theme-colour rules set --bs-text-opacity: 1 and read it back, so
.text-opacity-* fades them. The -emphasis and body utilities read a plain variable
and do not respond to it.
HTML
<div class="text-navy">This is default navy text</div>
<div class="text-navy text-opacity-75">This is 75% opacity navy text</div>
<div class="text-navy text-opacity-50">This is 50% opacity navy text</div>
<div class="text-navy text-opacity-25">This is 25% opacity navy text</div><div class="text-danger" style="--bs-text-opacity: .6">Danger text at 60%</div>
Specificity
Every colour utility is !important. Nested links inherit nothing from a parent's
.text-* — a link keeps --bs-link-color unless you give it its own class. Use the
colored link helpers for that.
Red text with a default navy link and a matching red link.
HTML
<p class="text-danger mb-0">Red text with a <a href="#!">default navy link</a> and a <a href="#!" class="link-danger">matching red link</a>.</p>CSS
.text-gold {
--bs-text-opacity: 1;
color: rgba(var(--bs-gold-rgb), var(--bs-text-opacity)) !important;
}
.text-primary-emphasis {
color: var(--bs-primary-text-emphasis) !important;
}
.text-body-secondary {
--bs-text-opacity: 1;
color: var(--bs-secondary-color) !important;
}
Light and dark values of the variables involved:
| Variable | Light | Dark |
|---|---|---|
--bs-primary-text-emphasis | #6b5410 | #e6c769 (gold-300) |
--bs-secondary-text-emphasis | #122553 (navy-700) | #c8d2e6 (navy-100) |
--bs-success-text-emphasis | #1b4d1e | #8fd092 |
--bs-info-text-emphasis | #0a1b3d (navy-900) | #c8d2e6 (navy-100) |
--bs-warning-text-emphasis | #6b5410 | #e6c769 (gold-300) |
--bs-danger-text-emphasis | #6b1712 | #f0a19a |
--bs-light-text-emphasis | #122553 (navy-700) | #faf3df (cream-50) |
--bs-dark-text-emphasis | #0a1b3d (navy-900) | #f4ecd8 (cream-100) |
--bs-body-color | #0a1b3d (navy-900) | #f4ecd8 (cream-100) |
--bs-emphasis-color | #000 | #faf3df (cream-50) |
--bs-secondary-color | #4a6398 (navy-400) | #c8d2e6 (navy-100) |
--bs-tertiary-color | rgba(10, 27, 61, .5) | rgba(244, 236, 216, .5) |
Sass
Emphasis colours are set per mode in scss/_variables.scss and scss/_variables-dark.scss, then merged into $theme-colors-text in scss/_maps.scss:
$primary-text-emphasis: #6b5410;
$primary-text-emphasis-dark: $rb-gold-300;
$theme-colors-text: map-merge(
( "primary": $primary-text-emphasis, /* … */ ),
( "gold": #6b5410, "navy": $rb-navy-900, "cream": $rb-navy-700 )
);
The .text-* classes are generated by the "color" entry in $utilities
from $utilities-text-colors; the emphasis classes from $utilities-text-emphasis-colors.
See the utility API, and Color for the palette.