core-logo

Colors

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

On this page:



Color

.c-text-primary

.c-text-secondary

.c-text-success

.c-text-danger

.c-text-warning

.c-text-info

.c-text-light

.c-text-dark

.c-text-body

.c-text-muted

.c-text-white

.c-text-black-50

.c-text-white-50

<p class="c-text-primary">.c-text-primary</p>
<p class="c-text-secondary">.c-text-secondary</p>
<p class="c-text-success">.c-text-success</p>
<p class="c-text-danger">.c-text-danger</p>
<p class="c-text-warning">.c-text-warning</p>
<p class="c-text-info">.c-text-info</p>
<p class="c-text-light c-bg-dark">.c-text-light</p>
<p class="c-text-dark">.c-text-dark</p>
<p class="c-text-body">.c-text-body</p>
<p class="c-text-muted">.c-text-muted</p>
<p class="c-text-white c-bg-dark">.c-text-white</p>
<p class="c-text-black-50">.c-text-black-50</p>
<p class="c-text-white-50 c-bg-dark">.c-text-white-50</p>

Contextual text classes also work well on anchors with the provided hover and focus states. Note that the .c-text-white and .c-text-muted class has no additional link styling beyond underline.

<p><a href="#" class="c-text-primary">Primary link</a></p>
<p><a href="#" class="c-text-secondary">Secondary link</a></p>
<p><a href="#" class="c-text-success">Success link</a></p>
<p><a href="#" class="c-text-danger">Danger link</a></p>
<p><a href="#" class="c-text-warning">Warning link</a></p>
<p><a href="#" class="c-text-info">Info link</a></p>
<p><a href="#" class="c-text-light c-bg-dark">Light link</a></p>
<p><a href="#" class="c-text-dark">Dark link</a></p>
<p><a href="#" class="c-text-muted">Muted link</a></p>
<p><a href="#" class="c-text-white c-bg-dark">White link</a></p>

Background color

Similar to the contextual text color classes, easily set the background of an element to any contextual class. Background utilities do not set color, so in some cases you’ll want to use .c-text-* utilities.

.c-bg-primary
.c-bg-secondary
.c-bg-success
.c-bg-danger
.c-bg-warning
.c-bg-info
.c-bg-light
.c-bg-dark
.c-bg-white
.c-bg-transparent
<div class="c-p-3 c-mb-2 c-bg-primary c-text-white">.c-bg-primary</div>
<div class="c-p-3 c-mb-2 c-bg-secondary c-text-white">.c-bg-secondary</div>
<div class="c-p-3 c-mb-2 c-bg-success c-text-white">.c-bg-success</div>
<div class="c-p-3 c-mb-2 c-bg-danger c-text-white">.c-bg-danger</div>
<div class="c-p-3 c-mb-2 c-bg-warning c-text-dark">.c-bg-warning</div>
<div class="c-p-3 c-mb-2 c-bg-info c-text-white">.c-bg-info</div>
<div class="c-p-3 c-mb-2 c-bg-light c-text-dark">.c-bg-light</div>
<div class="c-p-3 c-mb-2 c-bg-dark c-text-white">.c-bg-dark</div>
<div class="c-p-3 c-mb-2 c-bg-white c-text-dark">.c-bg-white</div>
<div class="c-p-3 c-mb-2 c-bg-transparent c-text-dark">.c-bg-transparent</div>

Background gradient

When $enable-gradients is set to true (default is false), you can use .c-bg-gradient- utility classes. Learn about our Sass options to enable these classes and more.

  • .c-bg-gradient-primary
  • .c-bg-gradient-secondary
  • .c-bg-gradient-success
  • .c-bg-gradient-danger
  • .c-bg-gradient-warning
  • .c-bg-gradient-info
  • .c-bg-gradient-light
  • .c-bg-gradient-dark

Dealing with 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> with the class.

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 .sr-only class.