Powered by NeGD | MeitY Government of India® UX4G
Color & Background
Set a background color with contrasting foreground color.
Overview #
added-in "1.0"
The capabilities of our .text-* utilities and .bg-* utilities are combined in a single class by color and background aids. We automatically choose a contrasting color for a specific backdrop color using the Sass color-contrast() method.
CAUTION
Heads up! There’s currently no support for a CSS-native
color-contrast
function, so we use our own via Sass. This means
that customizing our theme colors via CSS variables may cause color contrast
issues with these utilities.
RESULT
Primary with contrasting colorSecondary with contrasting colorSuccess with contrasting colorDanger with contrasting colorWarning with contrasting colorInfo with contrasting colorLight with contrasting colorDark with contrasting color
.visually-hidden
class.
With components #
Use them in place of combined .text-*
and
.bg-*
classes, like on badges:
<span class="badge text-bg-primary">Primary</span>
<span class="badge text-bg-info">Info</span>
RESULT
Or on cards:
<div class="card text-bg-primary mb-3" style="max-width: 18rem;">
<div class="card-header">Header</div>
<div class="card-body">
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</div>
</div>
<div class="card text-bg-info mb-3" style="max-width: 18rem;">
<div class="card-header">Header</div>
<div class="card-body">
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</div>
</div>
RESULT
HeaderSome quick example text to build on the card title and make up the bulk of the card's content.
HeaderSome quick example text to build on the card title and make up the bulk of the card's content.