Colors
Convey meaning through color
with a handful of color utility classes. Includes support for styling links with hover states, too.
.visually-hidden
class.
Colors
Some of the colors combinations below do not belong to the Orange Design System specifications, and do not meet accessibility standards.
Please refer to our Orange’s colors section underneath and to the Color guidelines on the Orange Design System website.
Colorize text with color utilities. If you want to colorize links, you can use the .link-*
helper classes which have :hover
and :focus
states.
.text-*
that generated from our original $theme-colors
Sass map don’t yet respond to color modes, however, any .text-*-emphasis
utility will. This will be resolved in v6.
.text-primary
.text-primary-emphasis
.text-secondary
.text-secondary-emphasis
.text-success
.text-success-emphasis
.text-danger
.text-danger-emphasis
.text-warning
.text-warning-emphasis
.text-info
.text-info-emphasis
.text-light
.text-light-emphasis
.text-dark
.text-dark-emphasis
.text-body
.text-body-emphasis
.text-body-secondary
.text-body-tertiary
.text-black
.text-white
.text-black-50
.text-white-50
<p class="text-primary bg-dark">.text-primary</p>
<p class="text-primary-emphasis bg-dark">.text-primary-emphasis</p>
<p class="text-secondary">.text-secondary</p>
<p class="text-secondary-emphasis ">.text-secondary-emphasis</p>
<p class="text-success bg-dark">.text-success</p>
<p class="text-success-emphasis bg-dark">.text-success-emphasis</p>
<p class="text-danger">.text-danger</p>
<p class="text-danger-emphasis ">.text-danger-emphasis</p>
<p class="text-warning bg-dark">.text-warning</p>
<p class="text-warning-emphasis bg-dark">.text-warning-emphasis</p>
<p class="text-info bg-dark">.text-info</p>
<p class="text-info-emphasis bg-dark">.text-info-emphasis</p>
<p class="text-light bg-dark">.text-light</p>
<p class="text-light-emphasis bg-dark">.text-light-emphasis</p>
<p class="text-dark">.text-dark</p>
<p class="text-dark-emphasis ">.text-dark-emphasis</p>
<p class="text-body">.text-body</p>
<p class="text-body-emphasis">.text-body-emphasis</p>
<p class="text-body-secondary">.text-body-secondary</p>
<p class="text-body-tertiary">.text-body-tertiary</p>
<p class="text-black bg-white">.text-black</p>
<p class="text-white bg-dark">.text-white</p>
<p class="text-black-50 bg-white">.text-black-50</p>
<p class="text-white-50 bg-dark">.text-white-50</p>
.text-opacity-*
utilities and CSS variables for text utilities, .text-black-50
and .text-white-50
are deprecated as of v5.1.0. They’ll be removed in v6.0.0.
.text-muted
utility has been deprecated as of v5.3.0. Its default value has also been reassigned to the new --bs-secondary-color
CSS variable to better support color modes. It will be removed in v6.0.0.
Orange’s colors
Bootstrap provides many .text-*
and .bg-*
utilities, but they should be used with care to meet our design specifications and WCAG 2.0 accessibility standards for color contrast.
To be sure to respect the specifications, it is necessary to define color
, background-color
and font-size
altogether.
Thus, the .text-primary
color on white background (#f16e00
) can only be used in a font size greater than 24px (using for example .fs-3
utility), or 19px bold (using for example .fs-4
and .fw-bold
utilities).
The .text-primary
color on dark background (#ff7900
) can be used in any size, and it shouldn’t be used on light grey backgrounds at all.
Here are some compliant combinations examples for texts:
regular black text
regular primary text with minimum font-size for contrast with .fs-3
regular secondary text
bold black text
bold primary text with minimum font-size for contrast with .fs-4
bold secondary text
regular white text on dark
regular primary text on dark
regular light text on dark
bold white text on dark
bold primary text on dark
bold light text on dark
<p class="text-black">regular black text</p>
<p class="text-primary fs-3">regular primary text with minimum font-size for contrast with .fs-3</p>
<p class="text-body-secondary">regular secondary text</p>
<p class="text-black fw-bold">bold black text</p>
<p class="text-primary fs-4 fw-bold">bold primary text with minimum font-size for contrast with .fs-4</p>
<p class="text-body-secondary fw-bold">bold secondary text</p>
<div class="bg-dark py-1">
<p class="text-white">regular white text on dark</p>
<p class="text-primary">regular primary text on dark</p>
<p class="text-light">regular light text on dark</p>
<p class="text-white fw-bold">bold white text on dark</p>
<p class="text-primary fw-bold">bold primary text on dark</p>
<p class="text-light fw-bold">bold light text on dark</p>
</div>
Here are some compliant combinations examples for non-texts elements, such as SVG icons:
<p class="p-2">
<svg width="1.875em" height="1.875em" class="text-primary" aria-hidden="true" focusable="false">
<use xlink:href="/docs/5.3/assets/img/boosted-sprite.svg#settings"/>
</svg>
<svg width="1.875em" height="1.875em" class="text-success" aria-hidden="true" focusable="false">
<use xlink:href="/docs/5.3/assets/img/boosted-sprite.svg#success"/>
</svg>
<svg width="1.875em" height="1.875em" class="text-danger" aria-hidden="true" focusable="false">
<use xlink:href="/docs/5.3/assets/img/boosted-sprite.svg#danger"/>
</svg>
<svg width="1.875em" height="1.875em" class="text-info" aria-hidden="true" focusable="false">
<use xlink:href="/docs/5.3/assets/img/boosted-sprite.svg#info"/>
</svg>
</p>
<p class="bg-dark p-2">
<svg width="1.875em" height="1.875em" class="text-primary" aria-hidden="true" focusable="false">
<use xlink:href="/docs/5.3/assets/img/boosted-sprite.svg#settings"/>
</svg>
<svg width="1.875em" height="1.875em" class="text-success" aria-hidden="true" focusable="false">
<use xlink:href="/docs/5.3/assets/img/boosted-sprite.svg#success"/>
</svg>
<svg width="1.875em" height="1.875em" class="text-danger" aria-hidden="true" focusable="false">
<use xlink:href="/docs/5.3/assets/img/boosted-sprite.svg#danger"/>
</svg>
<svg width="1.875em" height="1.875em" class="text-info" aria-hidden="true" focusable="false">
<use xlink:href="/docs/5.3/assets/img/boosted-sprite.svg#info"/>
</svg>
<svg width="1.875em" height="1.875em" class="text-warning" aria-hidden="true" focusable="false">
<use xlink:href="/docs/5.3/assets/img/boosted-sprite.svg#warning"/>
</svg>
</p>
Opacity
Added in v5.1.0
As of v5.1.0, text color utilities are generated with Sass using CSS variables. This allows for real-time color changes without compilation and dynamic alpha transparency changes.
How it works
Consider our default .text-primary
utility.
.text-primary {
--bs-text-opacity: 1;
color: rgba(var(--bs-primary-text-rgb), var(--bs-text-opacity)) !important;
}
We use an RGB version of our $accessible-orange
(with the value of 241, 110, 0
) Sass variable as a CSS variable and attached a second CSS variable, --bs-text-opacity
, for the alpha transparency (with a default value 1
thanks to a local CSS variable). That means anytime you use .text-primary
now, your computed color
value is rgba(241, 110, 0, 1)
. The local CSS variable inside each .text-*
class avoids inheritance issues so nested instances of the utilities don’t automatically have a modified alpha transparency.
When used in a dark variant context, --bs-primary-text-rgb
will use the value of $brand-orange
(with the value of 255, 121, 0
).
Example
To change that opacity, override --bs-text-opacity
via custom styles or inline styles.
<div class="text-primary">This is default primary text</div>
<div class="text-primary" style="--bs-text-opacity: .5;">This is 50% opacity primary text</div>
Or, choose from any of the .text-opacity
utilities:
<div class="text-primary">This is default primary text</div>
<div class="text-primary text-opacity-75">This is 75% opacity primary text</div>
<div class="text-primary text-opacity-50">This is 50% opacity primary text</div>
<div class="text-primary text-opacity-25">This is 25% opacity primary text</div>
Specificity
Sometimes contextual classes cannot be applied due to the specificity of another selector. In some cases, a sufficient workaround is to wrap your element’s content in a <div>
or more semantic element with the desired class.
CSS
In addition to the following Sass functionality, consider reading about our included CSS custom properties (aka CSS variables) for colors and more.
Sass variables
Most color
utilities are generated by our theme colors, reassigned from our generic color palette variables.
Boosted supersedes Bootstrap color variables with Orange brand color.
// Boosted mod
//// Core colors
$accessible-orange: #f16e00;
$brand-orange: #ff7900;
//// Functional colors
$functional-green: #32c832;
$functional-blue: #527edb;
$functional-yellow: #fc0;
$functional-red: #cd3c14;
//// Supporting colors
$supporting-blue: #4bb4e6;
$supporting-yellow: #ffd200;
$supporting-green: #50be87;
$supporting-purple: #a885d8;
$supporting-pink: #ffb4e6;
$blue: $functional-blue;
$indigo: $supporting-purple;
$purple: $supporting-purple;
$pink: $supporting-pink;
$red: $functional-red;
$orange: $brand-orange;
$yellow: $functional-yellow;
$green: $functional-green;
$teal: $supporting-green;
$cyan: $supporting-blue;
$primary: $orange;
$secondary: $black;
$success: $green;
$info: $blue;
$warning: $yellow;
$danger: $red;
$light: $gray-500;
$dark: $black;
Grayscale colors are also available, but only a subset are used to generate any utilities.
$white: #fff;
$gray-100: #fafafa;
$gray-200: #f6f6f6;
$gray-300: #eee;
$gray-400: #ddd;
$gray-500: #ccc;
$gray-600: #999;
$gray-700: #666;
$gray-800: #595959;
$gray-900: #333;
$black: #000;
$theme-colors-text: (
"primary": $primary-text-emphasis,
"secondary": $secondary-text-emphasis,
"success": $success-text-emphasis,
"info": $info-text-emphasis,
"warning": $warning-text-emphasis,
"danger": $danger-text-emphasis,
"light": $light-text-emphasis,
"dark": $dark-text-emphasis,
);
Variables for setting colors in .text-*-emphasis
utilities in light and dark mode:
$primary-text-emphasis: $accessible-orange; // Boosted mod: instead of `shade-color($primary, 60%)`
$secondary-text-emphasis: $secondary; // Boosted mod: instead of `shade-color($secondary, 60%)`
$success-text-emphasis: $success; // Boosted mod: instead of `shade-color($success, 60%)`
$info-text-emphasis: $info; // Boosted mod: instead of `shade-color($info, 60%)`
$warning-text-emphasis: $warning; // Boosted mod: instead of `shade-color($warning, 60%)`
$danger-text-emphasis: $danger; // Boosted mod: instead of `shade-color($danger, 60%)`
$light-text-emphasis: $light; // Boosted mod: instead of `$gray-700`
$dark-text-emphasis: $dark; // Boosted mod: instead of `$gray-700`
$primary-text-emphasis-dark: $primary; // Boosted mod: isntead of `tint-color($primary, 40%)`
$secondary-text-emphasis-dark: $secondary; // Boosted mod: instead of `tint-color($secondary, 40%)`
$success-text-emphasis-dark: $success; // Boosted mod: instead of `tint-color($success, 40%)`
$info-text-emphasis-dark: $info; // Boosted mod: instead of `tint-color($info, 40%)`
$warning-text-emphasis-dark: $warning; // Boosted mod: instead of `tint-color($warning, 40%)`
$danger-text-emphasis-dark: $danger; // Boosted mod: instead of `tint-color($danger, 40%)`
$light-text-emphasis-dark: $light; // Boosted mod: instead of `$gray-100`
$dark-text-emphasis-dark: $dark; // Boosted mod: instead of `$gray-300`
Sass maps
Theme colors are then put into a Sass map so we can loop over them to generate our utilities, component modifiers, and more.
$theme-colors: (
"primary": $primary,
"secondary": $secondary,
"success": $success,
"info": $info,
"warning": $warning,
"danger": $danger,
"light": $light,
"dark": $dark
);
Grayscale colors are also available as a Sass map. This map is not used to generate any utilities.
$grays: (
"100": $gray-100,
"200": $gray-200,
"300": $gray-300,
"400": $gray-400,
"500": $gray-500,
"600": $gray-600,
"700": $gray-700,
"800": $gray-800,
"900": $gray-900
);
RGB colors are generated from a separate Sass map:
$theme-colors-rgb: map-loop($theme-colors, to-rgb, "$value");
Color opacities build on that with their own map that’s consumed by the utilities API:
$utilities-text: map-merge(
$utilities-colors,
(
"primary": to-rgb($accessible-orange), // Boosted mod
"black": to-rgb($black),
"white": to-rgb($white),
"body": to-rgb($body-color)
)
);
$utilities-text-colors: map-loop($utilities-text, rgba-css-var, "$key", "text");
$utilities-text-emphasis-colors: (
"primary-emphasis": var(--#{$prefix}primary-text-emphasis),
"secondary-emphasis": var(--#{$prefix}secondary-text-emphasis),
"success-emphasis": var(--#{$prefix}success-text-emphasis),
"info-emphasis": var(--#{$prefix}info-text-emphasis),
"warning-emphasis": var(--#{$prefix}warning-text-emphasis),
"danger-emphasis": var(--#{$prefix}danger-text-emphasis),
"light-emphasis": var(--#{$prefix}light-text-emphasis),
"dark-emphasis": var(--#{$prefix}dark-text-emphasis)
);
Color mode adaptive text colors are also available as a Sass map:
$theme-colors-text: (
"primary": $primary-text-emphasis,
"secondary": $secondary-text-emphasis,
"success": $success-text-emphasis,
"info": $info-text-emphasis,
"warning": $warning-text-emphasis,
"danger": $danger-text-emphasis,
"light": $light-text-emphasis,
"dark": $dark-text-emphasis,
);
$theme-colors-text-dark: (
"primary": $primary-text-emphasis-dark,
"secondary": $secondary-text-emphasis-dark,
"success": $success-text-emphasis-dark,
"info": $info-text-emphasis-dark,
"warning": $warning-text-emphasis-dark,
"danger": $danger-text-emphasis-dark,
"light": $light-text-emphasis-dark,
"dark": $dark-text-emphasis-dark,
);
Sass utilities API
Color utilities are declared in our utilities API in scss/_utilities.scss
. Learn how to use the utilities API.
"color": (
property: color,
class: text,
local-vars: (
"text-opacity": 1
),
values: map-merge(
$utilities-text-colors,
(
"muted": var(--#{$prefix}secondary-color), // deprecated
"black-50": rgba($black, .5), // deprecated
"white-50": rgba($white, .5), // deprecated
"body-secondary": var(--#{$prefix}secondary-color),
"body-tertiary": var(--#{$prefix}tertiary-color),
"body-emphasis": var(--#{$prefix}emphasis-color),
"reset": inherit,
"primary": rgba(var(--#{$prefix}primary-text-rgb), var(--#{$prefix}text-opacity)), // Boosted mod: redefine primary value
)
)
),
"text-opacity": (
css-var: true,
class: text-opacity,
values: (
25: .25,
50: .5,
75: .75,
100: 1
)
),
"text-color": (
property: color,
class: text,
values: $utilities-text-emphasis-colors
),