Background Color

Utilities for controlling the background color of an element.

When selecting a background color, make sure the foreground color contrast passes a minimum WCAG accessibility rating of level AA.

Quick reference

ClassColor
bg-bodybg-body
bg-transparentbg-transparent bg-checkered
bg-whitebg-white
bg-blackbg-black
bg-primarybg-primary
bg-primary-subtlebg-primary-subtle
bg-discoverybg-discovery
bg-discovery-subtlebg-discovery-subtle
bg-secondarybg-secondary
bg-secondary-subtlebg-secondary-subtle
bg-successbg-success
bg-success-subtlebg-success-subtle
bg-dangerbg-danger
bg-danger-subtlebg-danger-subtle
bg-warningbg-warning
bg-warning-subtlebg-warning-subtle
bg-infobg-info
bg-info-subtlebg-info-subtle
bg-lightbg-light
bg-light-subtlebg-light-subtle
bg-darkbg-dark
bg-dark-subtlebg-dark-subtle
bg-body-secondarybg-body-secondary
bg-body-tertiarybg-body-tertiary

Basic usage

Setting the background color

Control the background color of an element using the bg-{color} utilities.

<button class="btn text-bg-warning ...">
  Save changes
</button>

Setting the background gradient

By adding a .bg-gradient class, a linear gradient is added as background image to the backgrounds. This gradient starts with a semi-transparent white which fades out to the bottom.

<button class="btn text-bg-primary bg-gradient ...">
 .bg-gradient
</button>

Changing the opacity

Control the opacity of an element’s background color using the color opacity .bg-opacity-* utilities.

bg-opacity-100
bg-opacity-100
bg-opacity-75
bg-opacity-50
bg-opacity-25
bg-opacity-10
<div class="bg-purple bg-opacity-100"></div>
<div class="bg-purple bg-opacity-75"></div>
<div class="bg-purple bg-opacity-50"></div>
...