Skip to main content Skip to docs navigation
Check

Convey meaning through color with a handful of color utility classes. Includes support for styling links with hover states, too.

Colors

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-primary

.text-secondary

.text-success

.text-danger

.text-warning

.text-info

.text-light

.text-dark

.text-maricopa-blue

.text-cgc-primary

.text-cgc-secondary

.text-emc-primary

.text-emc-secondary

.text-gcc-primary

.text-gcc-secondary

.text-gwc-primary

.text-gwc-secondary

.text-mcc-primary

.text-mcc-secondary

.text-pcc-primary

.text-pcc-secondary

.text-pvc-primary

.text-pvc-secondary

.text-rsc-primary

.text-rsc-secondary

.text-scc-primary

.text-scc-secondary

.text-smc-primary

.text-smc-secondary

.text-body

.text-muted

.text-white

.text-black-50

.text-white-50

html
<p class="text-primary">.text-primary</p>
<p class="text-secondary">.text-secondary</p>
<p class="text-success">.text-success</p>
<p class="text-danger">.text-danger</p>
<p class="text-warning bg-dark">.text-warning</p>
<p class="text-info">.text-info</p>
<p class="text-light bg-dark">.text-light</p>
<p class="text-dark">.text-dark</p>
<p class="text-maricopa-blue">.text-maricopa-blue</p>
<p class="text-cgc-primary">.text-cgc-primary</p>
<p class="text-cgc-secondary">.text-cgc-secondary</p>
<p class="text-emc-primary">.text-emc-primary</p>
<p class="text-emc-secondary bg-dark">.text-emc-secondary</p>
<p class="text-gcc-primary">.text-gcc-primary</p>
<p class="text-gcc-secondary">.text-gcc-secondary</p>
<p class="text-gwc-primary">.text-gwc-primary</p>
<p class="text-gwc-secondary">.text-gwc-secondary</p>
<p class="text-mcc-primary">.text-mcc-primary</p>
<p class="text-mcc-secondary">.text-mcc-secondary</p>
<p class="text-pcc-primary">.text-pcc-primary</p>
<p class="text-pcc-secondary bg-dark">.text-pcc-secondary</p>
<p class="text-pvc-primary">.text-pvc-primary</p>
<p class="text-pvc-secondary">.text-pvc-secondary</p>
<p class="text-rsc-primary">.text-rsc-primary</p>
<p class="text-rsc-secondary bg-dark">.text-rsc-secondary</p>
<p class="text-scc-primary">.text-scc-primary</p>
<p class="text-scc-secondary bg-dark">.text-scc-secondary</p>
<p class="text-smc-primary">.text-smc-primary</p>
<p class="text-smc-secondary">.text-smc-secondary</p>
<p class="text-body">.text-body</p>
<p class="text-muted">.text-muted</p>
<p class="text-white bg-dark">.text-white</p>
<p class="text-black-50">.text-black-50</p>
<p class="text-white-50 bg-dark">.text-white-50</p>
Deprecation: With the addition of .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.
Conveying meaning to assistive technologies

Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (e.g. the visible text), or is included through alternative means, such as additional text hidden with the .visually-hidden class.

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-rgb), var(--bs-text-opacity)) !important;
}

We use an RGB version of our --bs-primary (with the value of 13, 110, 253) 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(13, 110, 253, 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.

Example

To change that opacity, override --bs-text-opacity via custom styles or inline styles.

This is default primary text
This is 50% opacity primary text
html
<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:

This is default primary text
This is 75% opacity primary text
This is 50% opacity primary text
This is 25% opacity primary text
html
<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.

Sass

In addition to the following Sass functionality, consider reading about our included CSS custom properties (aka CSS variables) for colors and more.

Variables

Most color utilities are generated by our theme colors, reassigned from our generic color palette variables.

$blue:    #002b5c;
$indigo:  #0171bc;
$purple:  #6f42c1;
$pink:    #d63384;
$red:     #c10520;
$orange:  #fd7e14;
$yellow:  #f7d068;
$green:   #228736;
$teal:    #20c997;
$cyan:    #0057b8;
$skyblue: #d9edf7;
$primary:       $blue;
$secondary:     $indigo;
$success:       $green;
$info:          $cyan;
$warning:       $yellow;
$danger:        $red;
$light:         $gray-100;
$dark:          $gray-700;

Grayscale colors are also available, but only a subset are used to generate any utilities.

$white:    #fff;
$gray-100: #f2f2f2;
$gray-200: #e0e0e0;
$gray-300: #cccccc;
$gray-400: #999999;
$gray-500: #666666;
$gray-600: #545454;
$gray-700: #404040;
$gray-800: #262626;
$gray-900: #171717;
$black:    #000;

Map

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");

And color opacities build on that with their own map that’s consumed by the utilities API:

$utilities-text: map-merge(
  $utilities-colors,
  (
    "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 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": $text-muted,
          "black-50": rgba($black, .5), // deprecated
          "white-50": rgba($white, .5), // deprecated
          "reset": inherit,
        )
      )
    ),
    "text-opacity": (
      css-var: true,
      class: text-opacity,
      values: (
        25: .25,
        50: .5,
        75: .75,
        100: 1
      )
    ),