Utility

Contextual colours

Convey meaning through color with a handful of emphasis utility classes. These may also be applied to links and will darken on hover just like our default link styles.

Dealing with specificity

Sometimes emphasis classes cannot be applied due to the specificity of another selector. In most cases, a sufficient workaround is to wrap your text in a <span> 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 (the contextual colors are only used to reinforce meaning that is already present in the text/markup), or is included through alternative means, such as additional text hidden with the .sr-only class.

</p>

Muted

Primary.

Success

Info

Warning

Danger

<p class="text-muted">Muted</p>
<p class="text-primary">Primary.</p>
<p class="text-success">Success</p>
<p class="text-info">Info</p>
<p class="text-warning">Warning</p>
<p class="text-danger">Danger</p>

Contextual backgrounds

Similar to the contextual text color classes, easily set the background of an element to any contextual class. Anchor components will darken on hover, just like the text classes.

Dealing with specificity

Sometimes contextual background 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

As with contextual colors, ensure that any meaning conveyed through color is also conveyed in a format that is not purely presentational.

Muted

Primary

Success

Info

Warning

Danger

<p class="bg-muted">Muted</p>
<p class="bg-primary">Primary</p>
<p class="bg-success">Success</p>
<p class="bg-info">Info</p>
<p class="bg-warning">Warning</p>
<p class="bg-danger">Danger</p>

The background classes come with hover effects when applied to table rows. (Except when using .table-nohover)

bg-danger-light
bg-success-light
bg-warning-light
bg-info-light
bg-primary-light
bg-primary
bg-success
bg-info
bg-warning
bg-danger
<table class="table table-condensed">
  <tbody>
    <tr class="bg-danger-light">
      <td>bg-danger-light</td>
    </tr>
    <tr class="bg-success-light">
      <td>bg-success-light</td>
    </tr>
    <tr class="bg-warning-light">
      <td>bg-warning-light</td>
    </tr>
    <tr class="bg-info-light">
      <td>bg-info-light</td>
    </tr>
    <tr class="bg-primary-light">
      <td>bg-primary-light</td>
    </tr>
    <tr class="bg-primary">
      <td>bg-primary</td>
    </tr>
    <tr class="bg-success">
      <td>bg-success</td>
    </tr>
    <tr class="bg-info">
      <td>bg-info</td>
    </tr>
    <tr class="bg-warning">
      <td>bg-warning</td>
    </tr>
    <tr class="bg-danger">
      <td>bg-danger</td>
    </tr>
  </tbody>
</table>

Additional background colors

.bg-pomegranate
.bg-amaranth
.bg-seance
.bg-royal-purple
.bg-san-marino
.bg-blue-ribbon
.bg-cerulean
.bg-robins-egg-blue
.bg-gossamer
.bg-fruit-salad
.bg-sushi
.bg-wattle
.bg-bright-sun
.bg-amber
.bg-orange-peel
.bg-orange
.bg-coffee
.bg-silver-chalice
.bg-lynch
<div class="row">
  <div class="col flex-grow-0">
    <div class="bg-pomegranate text-white d-flex justify-content-center align-items-center rounded-xl mb-3" style="width:10em;height:10em;">
      .bg-pomegranate
    </div>
  </div>
  <div class="col flex-grow-0">
    <div class="bg-amaranth text-white d-flex justify-content-center align-items-center rounded-xl mb-3" style="width:10em;height:10em;">
      .bg-amaranth
    </div>
  </div>
  <div class="col flex-grow-0">
    <div class="bg-seance text-white d-flex justify-content-center align-items-center rounded-xl mb-3" style="width:10em;height:10em;">
      .bg-seance
    </div>
  </div>
  <div class="col flex-grow-0">
    <div class="bg-royal-purple text-white d-flex justify-content-center align-items-center rounded-xl mb-3" style="width:10em;height:10em;">
      .bg-royal-purple
    </div>
  </div>
  <div class="col flex-grow-0">
    <div class="bg-san-marino text-white d-flex justify-content-center align-items-center rounded-xl mb-3" style="width:10em;height:10em;">
      .bg-san-marino
    </div>
  </div>
  <div class="col flex-grow-0">
    <div class="bg-blue-ribbon text-white d-flex justify-content-center align-items-center rounded-xl mb-3" style="width:10em;height:10em;">
      .bg-blue-ribbon
    </div>
  </div>
  <div class="col flex-grow-0">
    <div class="bg-cerulean text-white d-flex justify-content-center align-items-center rounded-xl mb-3" style="width:10em;height:10em;">
      .bg-cerulean
    </div>
  </div>
  <div class="col flex-grow-0">
    <div class="bg-robins-egg-blue text-white d-flex justify-content-center align-items-center rounded-xl mb-3" style="width:10em;height:10em;">
      .bg-robins-egg-blue
    </div>
  </div>
  <div class="col flex-grow-0">
    <div class="bg-gossamer text-white d-flex justify-content-center align-items-center rounded-xl mb-3" style="width:10em;height:10em;">
      .bg-gossamer
    </div>
  </div>
  <div class="col flex-grow-0">
    <div class="bg-fruit-salad text-white d-flex justify-content-center align-items-center rounded-xl mb-3" style="width:10em;height:10em;">
      .bg-fruit-salad
    </div>
  </div>
  <div class="col flex-grow-0">
    <div class="bg-sushi d-flex justify-content-center align-items-center rounded-xl mb-3" style="width:10em;height:10em;">
      .bg-sushi
    </div>
  </div>
  <div class="col flex-grow-0">
    <div class="bg-wattle d-flex justify-content-center align-items-center rounded-xl mb-3" style="width:10em;height:10em;">
      .bg-wattle
    </div>
  </div>
  <div class="col flex-grow-0">
    <div class="bg-bright-sun d-flex justify-content-center align-items-center rounded-xl mb-3" style="width:10em;height:10em;">
      .bg-bright-sun
    </div>
  </div>
  <div class="col flex-grow-0">
    <div class="bg-amber d-flex justify-content-center align-items-center rounded-xl mb-3" style="width:10em;height:10em;">
      .bg-amber
    </div>
  </div>
  <div class="col flex-grow-0">
    <div class="bg-orange-peel d-flex justify-content-center align-items-center rounded-xl mb-3" style="width:10em;height:10em;">
      .bg-orange-peel
    </div>
  </div>
  <div class="col flex-grow-0">
    <div class="bg-orange text-white d-flex justify-content-center align-items-center rounded-xl mb-3" style="width:10em;height:10em;">
      .bg-orange
    </div>
  </div>
  <div class="col flex-grow-0">
    <div class="bg-coffee text-white d-flex justify-content-center align-items-center rounded-xl mb-3" style="width:10em;height:10em;">
      .bg-coffee
    </div>
  </div>
  <div class="col flex-grow-0">
    <div class="bg-silver-chalice text-white d-flex justify-content-center align-items-center rounded-xl mb-3" style="width:10em;height:10em;">
      .bg-silver-chalice
    </div>
  </div>
  <div class="col flex-grow-0">
    <div class="bg-lynch text-white d-flex justify-content-center align-items-center rounded-xl mb-3" style="width:10em;height:10em;">
      .bg-lynch
    </div>
  </div>
</div>

Element sizing

To control sizes of an element we can use classes below. The classes .element, *-sm and *-lg variants match the height of the same variant input.

Only control height:

.element-xs
.element-sm
.element
.element-lg
.element-xl
<div class="row text-center">
  <div class="col">
    <div class="element-xs border-2">
      <code>.element-xs</code>
    </div>
  </div>
  <div class="col">
    <div class="element-sm border-2">
      <code>.element-sm</code>
    </div>
  </div>
  <div class="col">
    <div class="element  border-2">
      <code>.element</code>
    </div>
  </div>
  <div class="col">
    <div class="element-lg border-2">
      <code>.element-lg</code>
    </div>
  </div>
  <div class="col">
    <div class="element-xl border-2">
      <code>.element-xl</code>
    </div>
  </div>
</div>

Keep aspect ratio 1:1

Add .element-1by1 to keep width and height the same.

<div class="row text-center">
  <div class="col">
    <div class="element-xs element-1by1 border-2 mb-2"></div>
    <div class="element-sm element-1by1 border-2 mb-2"></div>
    <div class="element element-1by1 border-2 mb-2"></div>
    <div class="element-lg element-1by1 border-2 mb-2"></div>
    <div class="element-xl element-1by1 border-2"></div>
  </div>
</div>

Close icon

Use the generic close icon for dismissing content like modals and alerts.

<button type="button" class="close" aria-label="Close"><span aria-hidden="true">&times;</span></button>

Spinners

Load animation only .loader

Loading...
<div class="spinner-border" role="status">
  <span class="sr-only">Loading...</span>
</div>
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
<div class="spinner-border text-primary" role="status">
  <span class="sr-only">Loading...</span>
</div>
<div class="spinner-border text-secondary" role="status">
  <span class="sr-only">Loading...</span>
</div>
<div class="spinner-border text-success" role="status">
  <span class="sr-only">Loading...</span>
</div>
<div class="spinner-border text-danger" role="status">
  <span class="sr-only">Loading...</span>
</div>
<div class="spinner-border text-warning" role="status">
  <span class="sr-only">Loading...</span>
</div>
<div class="spinner-border text-info" role="status">
  <span class="sr-only">Loading...</span>
</div>
<div class="spinner-border text-light" role="status">
  <span class="sr-only">Loading...</span>
</div>
<div class="spinner-border text-dark" role="status">
  <span class="sr-only">Loading...</span>
</div>

Growing spinner

If you don’t fancy a border spinner, switch to the grow spinner. While it doesn’t technically spin, it does repeatedly grow!

Loading...
<div class="spinner-grow" role="status">
  <span class="sr-only">Loading...</span>
</div>
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
<div class="spinner-grow text-primary" role="status">
  <span class="sr-only">Loading...</span>
</div>
<div class="spinner-grow text-secondary" role="status">
  <span class="sr-only">Loading...</span>
</div>
<div class="spinner-grow text-success" role="status">
  <span class="sr-only">Loading...</span>
</div>
<div class="spinner-grow text-danger" role="status">
  <span class="sr-only">Loading...</span>
</div>
<div class="spinner-grow text-warning" role="status">
  <span class="sr-only">Loading...</span>
</div>
<div class="spinner-grow text-info" role="status">
  <span class="sr-only">Loading...</span>
</div>
<div class="spinner-grow text-light" role="status">
  <span class="sr-only">Loading...</span>
</div>
<div class="spinner-grow text-dark" role="status">
  <span class="sr-only">Loading...</span>
</div>

Quick floats

Float an element to the left or right with a class. !important is included to avoid specificity issues. Classes can also be used as mixins.

Easily clear floats by adding .clearfix to the parent element. Utilizes the micro clearfix as popularized by Nicolas Gallagher.

left
right
<div class="clearfix">
  <div class="float-left">left</div>
  <div class="float-right">right</div>
</div>

Not for use in navbars

To align components in navbars with utility classes, use .navbar-left or .navbar-right instead. See the navbar docs for details.

Showing and hiding content

Force an element to be shown or hidden (including for screen readers) with the use of .show and .hidden classes. These classes use !important to avoid specificity conflicts, just like the quick floats. They are only available for block level toggling. They can also be used as mixins.

Furthermore, .invisible can be used to toggle only the visibility of an element, meaning its display is not modified and the element can still affect the flow of the document.

Screen reader and keyboard navigation content

Hide an element to all devices except screen readers with .sr-only. Combine .sr-only with .sr-only-focusable to show the element again when it’s focused (e.g. by a keyboard-only user). Necessary for following accessibility best practices. Can also be used as mixins.

<a class="sr-only sr-only-focusable" href="#">Skip to main content</a>

Image replacement

Utilize the .d-none class to help replace an element’s text content with a background image.

Custom heading

<h1 class="d-none">Custom heading</h1>