Skip to content

Background

The background foundation allows you to apply consistent background colors across components using a predefined map of color tokens.


.f--background-{variation}
  • {variation} represents a predefined background color key
  • Each variation maps to a color token defined in the system

Background foundation classes are generated using a loop that iterates over a map of background color options. The loop goes through:

  • A map of background color keys
  • Their corresponding color variables
$colorbg-options: (
a: $color-a,
b: $color-b,
c: $color-c,
);

For each entry in the map, a .f--background-{variation} class is generated and assigned the corresponding background color.


<div class="f--background-a">Background A</div>
<div class="f--background-b">Background B</div>
// using @extend (recommended)
.c--component-a {
@extend .f--background-a;
}
// using the mixin directly (only if necessary)
.c--component-a {
background: map-get($colorbg-options, a);
}

Knowledge Check

Test your understanding of this section

Loading questions...