diff options
author | Mark Otto <markdotto@gmail.com> | 2022-04-28 06:40:23 +0300 |
---|---|---|
committer | Mark Otto <otto@github.com> | 2022-04-30 22:55:27 +0300 |
commit | 8cd3c3e3bc6b966c2be9491091ad1c0c629a4b30 (patch) | |
tree | 757fa297a0bb15fbaeedfabc581c74b3c2c15510 /site | |
parent | ec41392717c767ae0c862e30967774e9a5d6ba7a (diff) |
Add new text-bg-color utilities
Diffstat (limited to 'site')
-rw-r--r-- | site/content/docs/5.1/helpers/color-background.md | 52 | ||||
-rw-r--r-- | site/data/sidebar.yml | 1 |
2 files changed, 53 insertions, 0 deletions
diff --git a/site/content/docs/5.1/helpers/color-background.md b/site/content/docs/5.1/helpers/color-background.md new file mode 100644 index 0000000000..c4174845c6 --- /dev/null +++ b/site/content/docs/5.1/helpers/color-background.md @@ -0,0 +1,52 @@ +--- +layout: docs +title: Color & background +description: Set a background color with contrasting foreground color. +group: helpers +toc: true +added: "5.2" +--- + +## Overview + +{{< added-in "5.2.0" >}} + +Color and background helpers combine the power of our [`.text-*` utilities]({{< docsref "/utilities/colors" >}}) and [`.bg-*` utilities]({{< docsref "/utilities/background" >}}) in one class. Using our Sass `color-contrast()` function, we automatically determine a contrasting `color` for a particular `background-color`. + +{{< callout warning >}} +**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. +{{< /callout >}} + +{{< example >}} +{{< text-bg.inline >}} +{{- range (index $.Site.Data "theme-colors") }} +<div class="text-bg-{{ .name }} p-3">{{ .name | title }} with contrasting color</div> +{{- end -}} +{{< /text-bg.inline >}} +{{< /example >}} + +## With components + +Use them in place of combined `.text-*` and `.bg-*` classes, like on [badges]({{< docsref "/components/badge#background-colors" >}}): + +{{< example >}} +<span class="badge text-bg-primary">Primary</span> +<span class="badge text-bg-info">Info</span> +{{< /example >}} + +Or on [cards]({{< docsref "/components/card#background-and-color" >}}): + +{{< example >}} +<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> +{{< /example >}} diff --git a/site/data/sidebar.yml b/site/data/sidebar.yml index eb03285c5f..cdf0b04d8b 100644 --- a/site/data/sidebar.yml +++ b/site/data/sidebar.yml @@ -100,6 +100,7 @@ icon_color: orange pages: - title: Clearfix + - title: Color & background - title: Colored links - title: Ratio - title: Position |