Gaps

Gap spacing utilities for grid and flex display with module mixins for responsive modifiers.

Utilities (anchor)

Gap utilities and property values
Utility name Property values
Gap
.gap-0 gap: 0
.gap-1 gap: 0.25rem
.gap-2 gap: 0.5rem
.gap-3 gap: 1rem
.gap-4 gap: 1.5rem
.gap-5 gap: 2rem
Column gap
.gap-c-0 column-gap: 0
.gap-c-1 column-gap: 0.25rem
.gap-c-2 column-gap: 0.5rem
.gap-c-3 column-gap: 1rem
.gap-c-4 column-gap: 1.5rem
.gap-c-5 column-gap: 2rem
Row gap
.gap-r-0 row-gap: 0
.gap-r-1 row-gap: 0.25rem
.gap-r-2 row-gap: 0.5rem
.gap-r-3 row-gap: 1rem
.gap-r-4 row-gap: 1.5rem
.gap-r-5 row-gap: 2rem

Responsive mixins (anchor)

Responsive modifier mixins are provided to include where required in custom breakpoints, the utilities available use the following modifier class naming convention:

.gap-1
.gap-1-xxl
.gap-1-xl
.gap-1-lg
.gap-1-md
.gap-1-sm
.gap-1-xs
.gap-1-xxs

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 gaps-css;

// Example breakpoint
@media (width <= 480px) {
  @include gaps-sm-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 (and required breakpoints) in an overrides document:

overrides.scss
@use "stylemods/scss/configuration" as *;
$enable-gaps:      true;
$enable-gaps-sm:   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 framework use the same source code, see Sass variables and Sass maps on the customizing page to learn how to customize the containers styles.

gaps.scss
// ---------------------------------------------------------- 
// Gaps
// ----------------------------------------------------------
$gap-0:   0 !default;
$gap-1:   0.25rem !default;
$gap-2:   0.5rem !default;
$gap-3:   1rem !default;
$gap-4:   1.5rem !default;
$gap-5:   2rem !default;

$gap-sizes: (
  "0": $gap-0,
  "1": $gap-1,
  "2": $gap-2,
  "3": $gap-3,
  "4": $gap-4,
  "5": $gap-5,
) !default;

@mixin gaps-css {  
  @each $name, $value in $gap-sizes {
  .gap-#{$name} {
      gap: #{$value};        
    }
  }
  
  @each $name, $value in $gap-sizes {
  .gap-c-#{$name} {
      column-gap: #{$value};        
    }
  }
  
  @each $name, $value in $gap-sizes {
  .gap-r-#{$name} {
      row-gap: #{$value};        
    }
  }
}

@mixin gaps-xxl-css {  
  @each $name, $value in $gap-sizes {
  .gap-#{$name}-xxl {
      gap: #{$value};        
    }
  }
  
  @each $name, $value in $gap-sizes {
  .gap-c-#{$name}-xxl {
      column-gap: #{$value};        
    }
  }
  
  @each $name, $value in $gap-sizes {
  .gap-r-#{$name}-xxl {
      row-gap: #{$value};        
    }
  }
}

@mixin gaps-xl-css {  
  @each $name, $value in $gap-sizes {
  .gap-#{$name}-xl {
      gap: #{$value};        
    }
  }
  
  @each $name, $value in $gap-sizes {
  .gap-c-#{$name}-xl {
      column-gap: #{$value};        
    }
  }
  
  @each $name, $value in $gap-sizes {
  .gap-r-#{$name}-xl {
      row-gap: #{$value};        
    }
  }
}

@mixin gaps-lg-css {  
  @each $name, $value in $gap-sizes {
  .gap-#{$name}-lg {
      gap: #{$value};        
    }
  }
  
  @each $name, $value in $gap-sizes {
  .gap-c-#{$name}-lg {
      column-gap: #{$value};        
    }
  }
  
  @each $name, $value in $gap-sizes {
  .gap-r-#{$name}-lg {
      row-gap: #{$value};        
    }
  }
}

@mixin gaps-md-css {  
  @each $name, $value in $gap-sizes {
  .gap-#{$name}-md {
      gap: #{$value};        
    }
  }
  
  @each $name, $value in $gap-sizes {
  .gap-c-#{$name}-md {
      column-gap: #{$value};        
    }
  }
  
  @each $name, $value in $gap-sizes {
  .gap-r-#{$name}-md {
      row-gap: #{$value};        
    }
  }
}

@mixin gaps-sm-css {  
  @each $name, $value in $gap-sizes {
  .gap-#{$name}-sm {
      gap: #{$value};        
    }
  }
  
  @each $name, $value in $gap-sizes {
  .gap-c-#{$name}-sm {
      column-gap: #{$value};        
    }
  }
  
  @each $name, $value in $gap-sizes {
  .gap-r-#{$name}-sm {
      row-gap: #{$value};        
    }
  }
}

@mixin gaps-xs-css {  
  @each $name, $value in $gap-sizes {
  .gap-#{$name}-xs {
      gap: #{$value};        
    }
  }
  
  @each $name, $value in $gap-sizes {
  .gap-c-#{$name}-xs {
      column-gap: #{$value};        
    }
  }
  
  @each $name, $value in $gap-sizes {
  .gap-r-#{$name}-xs {
      row-gap: #{$value};        
    }
  }
}

@mixin gaps-xxs-css {  
  @each $name, $value in $gap-sizes {
  .gap-#{$name}-xxs {
      gap: #{$value};        
    }
  }
  
  @each $name, $value in $gap-sizes {
  .gap-c-#{$name}-xxs {
      column-gap: #{$value};        
    }
  }
  
  @each $name, $value in $gap-sizes {
  .gap-r-#{$name}-xxs {
      row-gap: #{$value};        
    }
  }
}