Backgrounds
A variable utility for to provide custom background and text colors inline.
Examples (anchor)
The background color utility is a variable class with no preset values designed to be used to create custom background colors inline, it includes variables for text and background colors as demonstrated below.
<div class="bg" style="--bg-col:RoyalBlue; --bg-text:white;">RoyalBlue</div>
<div class="bg" style="--bg-col:Indigo; --bg-text:white;">Indigo</div>
<div class="bg" style="--bg-col:Maroon; --bg-text:white;">Maroon</div>
<div class="bg" style="--bg-col:Moccasin; --bg-text:black;">Moccasin</div>
<div class="bg" style="--bg-col:Thistle; --bg-text:black;">Thistle</div>
<div class="bg" style="--bg-col:PaleGreen; --bg-text:black;">PaleGreen</div>The color utilities use the variables to provide optional modifier classes for the .bg utility using the preset color values included with the color variables tokens.
See the gradients utilities for background image gradient styles, and the images utilities for specific background image related styles and variable utilities.
Using the module (anchor)
Load StyleMods as demonstrated (change file path as required) then include the Sass mixin anywhere below.
@use "stylemods/scss" as *;
@include background-css;See the using modules page for more information including how to compile the modules in cascade layers and include and reuse them in multiple source files.
Using the framework (anchor)
Using the recommended custom setup enable the styles in an overrides document:
@use "stylemods/scss/configuration" as *;
$enable-backgrounds: true;Include the overrides and the framework styles with your custom document for compiling the framework:
@use "overrides";
@use "stylemods/scss/stylemods";See using the framework for more information including how the styles can also be compiled within cascade layers.
Source code (anchor)
The modules and the framework follow the same methods for customizing the default values and using the CSS variables to create custom theme documents. See the customizing page for more information.
backgrounds.scss
// ----------------------------------------------------------
// Backgrounds
// ----------------------------------------------------------
$background-utility: bg !default;
$background-text-variable: var(--bg-text) !default;
$background-color-variable: var(--bg-col) !default;
@mixin background-css {
.#{$background-utility} {
color: $background-text-variable;
background-color: $background-color-variable;
}
}