Gradients

Utilities and variables for mono gradient overlays for solid backgrounds.

Examples (anchor)

Three basic mono linear-gradient background-image utilities to overlay solid background colors, also available as CSS variables to use in custom styles. Any color can be used, the examples use the optional background and color utilities.

Light
Default
Heavy
<div class="bg bg-blue gradient-light">Light</div>
<div class="bg bg-blue gradient">Default</div>
<div class="bg bg-blue gradient-heavy">Heavy</div>

Using the module (anchor)

Load StyleMods as demonstrated (change file path as required) then include the Sass mixin anywhere below.

custom.scss
@use "stylemods/scss" as *;
@include gradients-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:

overrides.scss
@use "stylemods/scss/configuration" as *;
$enable-gradients: true;

Include the overrides and the framework styles with your custom document for compiling the framework:

custom.scss
@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.

gradients.scss
// ---------------------------------------------------------- 
// Gradients
// ----------------------------------------------------------
$gradient-tokens:     ':where(html)' !default;
$gradient-default:    linear-gradient(180deg, rgba(white, .225), rgba(white, 0)) !default;
$gradient-light:      linear-gradient(180deg, rgba(white, .175), rgba(white, 0)) !default;
$gradient-heavy:      linear-gradient(180deg, rgba(white, .33), rgba(white, 0)) !default;

@mixin gradient-variables {
  --gradient: #{$gradient-default};
  --gradient-light: #{$gradient-light};
  --gradient-heavy: #{$gradient-heavy};
}

@mixin gradient-variables-css {
  #{$gradient-tokens} {
    @include gradient-variables;
  }
}

@mixin gradient-classes {
  .gradient {
    background-image: var(--gradient);
  }

  .gradient-light {
    background-image: var(--gradient-light);
  }

  .gradient-heavy {
    background-image: var(--gradient-heavy);
  }
}

@mixin gradient-novariables-css {
  .gradient {
    background-image: $gradient-default;
  }

  .gradient-light {
    background-image: $gradient-light;
  }

  .gradient-heavy {
    background-image: $gradient-heavy;
  }
}

@mixin gradients-css {
  #{$gradient-tokens} {
    @include gradient-variables;
  }  
  @include gradient-classes;
}