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)

To use the module load the StyleMods scss directory as follows (changing the path to suit the source files location as required) then include the Sass mixin anywhere below.

custom.scss
@use "stylemods/scss" as *;
@include gradients-css;

Source code (anchor)

See customizing for information about using the Sass and CSS variables in the source code to customize the styles, and Sass functionality (on the using StyleMods page) for other ways to use the variables to create custom styles.

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-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;
}