Borders

Basic border utility classes with module mixins for compiling responsive modifier classes.

Examples (anchor)

.bd
.bd-t
.bd-b
.bd-s
.bd-e
.bd-y
.bd-x
Example HTML
<div class="bd">.bd</div>
<div class="bd-t py-3">.bd-t</div>
<div class="bd-b py-3">.bd-b</div>
<div class="bd-s py-3">.bd-s</div>
<div class="bd-e py-3">.bd-e</div>
<div class="bd-y py-3">.bd-y</div>
<div class="bd-x py-3">.bd-x</div>
.rd-1
.rd-2
.rd-3
.rd-4
.rd-5
.rd-pill
Example HTML
<div class="rd-1 bd py-3">.rd-1</div>
<div class="rd-2 bd py-3">.rd-2</div>
<div class="rd-3 bd py-3">.rd-3</div>
<div class="rd-4 bd py-3">.rd-4</div>
<div class="rd-5 bd py-3">.rd-5</div>
<div class="rd-pill bd py-3">.rd-pill</div>
.rd-5-top
.rd-5-bottom
.rd-5-start
.rd-5-end
Example HTML
<div class="rd-5-top bd py-3">.rd-5-top</div>
<div class="rd-5-bottom bd py-3">.rd-5-bottom</div>
<div class="rd-5-start bd py-3">.rd-5-start</div>
<div class="rd-5-end bd py-3">.rd-5-end</div>
Example HTML
<div class="rd-circle bd" style="width: 6rem; height: 6rem;"></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 borders-css;

Borders also have responsive modifier mixins that can be included in custom breakpoints:

custom.scss
@use "stylemods/scss" as *;
@include borders-css;
@media (max-width: 480px) {
  @include borders-sm-css;
}

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

Source code (anchor)

borders.scss
// ---------------------------------------------------------- 
// Borders
// ----------------------------------------------------------
$border-width:    var(--bd-width, 1px) !default;
$border-color:    var(--bd-color, color-mix(in srgb, CanvasText 15%, Canvas)) !default;
$border-default:  $border-width solid $border-color !default;

$radius-1:        0.188rem !default;
$radius-2:        0.313rem !default;
$radius-3:        0.5rem !default;
$radius-4:        0.75rem !default;
$radius-5:        1.125rem !default;
$radius-pill:     50rem !default;
$radius-circle:   50% !default;

$border-radius: (
  "rd-1": $radius-1,
  "rd-2": $radius-2,
  "rd-3": $radius-3,
  "rd-4": $radius-4,
  "rd-5": $radius-5,
  "rd-pill": $radius-pill,
) !default;

$border-radius-circle: (
  "rd-circle": $radius-circle,
) !default;

$border-position: (
  "bd": border,
  "bd-t": border-block-start,
  "bd-b": border-block-end,
  "bd-y": border-block,
  "bd-x": border-inline,
  "bd-s": border-inline-start,
  "bd-e": border-inline-end,
) !default;

@mixin borders-css {

@each $name, $value in $border-position {
  .#{$name} {
    #{$value}: $border-default;        
  }
}

.bd-child * {
  border: $border-default;
}

// Radius
@each $name, $value in $border-radius {
  .#{$name} {
    border-radius: #{$value};        
  }
}

@each $name, $value in $border-radius-circle {
  .#{$name} {
    border-radius: #{$value};        
  }
}

@each $name, $value in $border-radius {
  .#{$name}-top {
    border-start-start-radius: #{$value};
    border-start-end-radius: #{$value};     
  }
}

@each $name, $value in $border-radius {
  .#{$name}-bottom {
    border-end-start-radius: #{$value};
    border-end-end-radius: #{$value};     
  }
}

@each $name, $value in $border-radius {
  .#{$name}-start {
    border-start-start-radius: #{$value};
    border-end-start-radius: #{$value};   
  }
}

@each $name, $value in $border-radius {
  .#{$name}-end {
    border-start-end-radius: #{$value};
    border-end-end-radius: #{$value};    
  }
}

} // end borders-css

// Border breakpoints
// XXL
@mixin borders-xxl-css {
  @each $name, $value in $border-position {
    .#{$name}-xxl {
      #{$value}: $border-default;        
    }
  }
}

// XL
@mixin borders-xl-css {
  @each $name, $value in $border-position {
    .#{$name}-xl {
      #{$value}: $border-default;        
    }
  }
}

// LG
@mixin borders-lg-css {
  @each $name, $value in $border-position {
    .#{$name}-lg {
      #{$value}: $border-default;        
    }
  }
}

// MD
@mixin borders-md-css {
  @each $name, $value in $border-position {
    .#{$name}-md {
      #{$value}: $border-default;        
    }
  }
}

// SM
@mixin borders-sm-css {
  @each $name, $value in $border-position {
    .#{$name}-sm {
      #{$value}: $border-default;        
    }
  }
}

// XS
@mixin borders-xs-css {
  @each $name, $value in $border-position {
    .#{$name}-xs {
      #{$value}: $border-default;        
    }
  }
}

// XXS
@mixin borders-xxs-css {
  @each $name, $value in $border-position {
    .#{$name}-xxs {
      #{$value}: $border-default;        
    }
  }
}

// Border radius breakpoints
// XXL
@mixin border-radius-xxl-css {
  @each $name, $value in $border-radius {
    .#{$name}-xxl {
      border-radius: #{$value};        
    }
  }
  
  @each $name, $value in $border-radius-circle {
    .#{$name}-xxl {
      border-radius: #{$value};        
    }
  }
  
  @each $name, $value in $border-radius {
    .#{$name}-top-xxl {
      border-start-start-radius: #{$value};
      border-start-end-radius: #{$value};     
    }
  }
  
  @each $name, $value in $border-radius {
    .#{$name}-bottom-xxl {
      border-end-start-radius: #{$value};
      border-end-end-radius: #{$value};     
    }
  }
  
  @each $name, $value in $border-radius {
    .#{$name}-start-xxl {
      border-start-start-radius: #{$value};
      border-end-start-radius: #{$value};   
    }
  }
  
  @each $name, $value in $border-radius {
    .#{$name}-end-xxl {
      border-start-end-radius: #{$value};
      border-end-end-radius: #{$value};    
    }
  }
}

// XL
@mixin border-radius-xl-css {
  @each $name, $value in $border-radius {
    .#{$name}-xl {
      border-radius: #{$value};        
    }
  }
  
  @each $name, $value in $border-radius-circle {
    .#{$name}-xl {
      border-radius: #{$value};        
    }
  }
  
  @each $name, $value in $border-radius {
    .#{$name}-top-xl {
      border-start-start-radius: #{$value};
      border-start-end-radius: #{$value};     
    }
  }
  
  @each $name, $value in $border-radius {
    .#{$name}-bottom-xl {
      border-end-start-radius: #{$value};
      border-end-end-radius: #{$value};     
    }
  }
  
  @each $name, $value in $border-radius {
    .#{$name}-start-xl {
      border-start-start-radius: #{$value};
      border-end-start-radius: #{$value};   
    }
  }
  
  @each $name, $value in $border-radius {
    .#{$name}-end-xl {
      border-start-end-radius: #{$value};
      border-end-end-radius: #{$value};    
    }
  }
}

// LG
@mixin border-radius-lg-css {
  @each $name, $value in $border-radius {
    .#{$name}-lg {
      border-radius: #{$value};        
    }
  }
  
  @each $name, $value in $border-radius-circle {
    .#{$name}-lg {
      border-radius: #{$value};        
    }
  }
  
  @each $name, $value in $border-radius {
    .#{$name}-top-lg {
      border-start-start-radius: #{$value};
      border-start-end-radius: #{$value};     
    }
  }
  
  @each $name, $value in $border-radius {
    .#{$name}-bottom-lg {
      border-end-start-radius: #{$value};
      border-end-end-radius: #{$value};     
    }
  }
  
  @each $name, $value in $border-radius {
    .#{$name}-start-lg {
      border-start-start-radius: #{$value};
      border-end-start-radius: #{$value};   
    }
  }
  
  @each $name, $value in $border-radius {
    .#{$name}-end-lg {
      border-start-end-radius: #{$value};
      border-end-end-radius: #{$value};    
    }
  }
}

// MD
@mixin border-radius-md-css {
  @each $name, $value in $border-radius {
    .#{$name}-md {
      border-radius: #{$value};        
    }
  }
  
  @each $name, $value in $border-radius-circle {
    .#{$name}-md {
      border-radius: #{$value};        
    }
  }
  
  @each $name, $value in $border-radius {
    .#{$name}-top-md {
      border-start-start-radius: #{$value};
      border-start-end-radius: #{$value};     
    }
  }
  
  @each $name, $value in $border-radius {
    .#{$name}-bottom-md {
      border-end-start-radius: #{$value};
      border-end-end-radius: #{$value};     
    }
  }
  
  @each $name, $value in $border-radius {
    .#{$name}-start-md {
      border-start-start-radius: #{$value};
      border-end-start-radius: #{$value};   
    }
  }
  
  @each $name, $value in $border-radius {
    .#{$name}-end-md {
      border-start-end-radius: #{$value};
      border-end-end-radius: #{$value};    
    }
  }
}


// SM
@mixin border-radius-sm-css {
  @each $name, $value in $border-radius {
    .#{$name}-sm {
      border-radius: #{$value};        
    }
  }
  
  @each $name, $value in $border-radius-circle {
    .#{$name}-sm {
      border-radius: #{$value};        
    }
  }
  
  @each $name, $value in $border-radius {
    .#{$name}-top-sm {
      border-start-start-radius: #{$value};
      border-start-end-radius: #{$value};     
    }
  }
  
  @each $name, $value in $border-radius {
    .#{$name}-bottom-sm {
      border-end-start-radius: #{$value};
      border-end-end-radius: #{$value};     
    }
  }
  
  @each $name, $value in $border-radius {
    .#{$name}-start-sm {
      border-start-start-radius: #{$value};
      border-end-start-radius: #{$value};   
    }
  }
  
  @each $name, $value in $border-radius {
    .#{$name}-end-sm {
      border-start-end-radius: #{$value};
      border-end-end-radius: #{$value};    
    }
  }
}

// XS
@mixin border-radius-xs-css {
  @each $name, $value in $border-radius {
    .#{$name}-xs {
      border-radius: #{$value};        
    }
  }
  
  @each $name, $value in $border-radius-circle {
    .#{$name}-xs {
      border-radius: #{$value};        
    }
  }
  
  @each $name, $value in $border-radius {
    .#{$name}-top-xs {
      border-start-start-radius: #{$value};
      border-start-end-radius: #{$value};     
    }
  }
  
  @each $name, $value in $border-radius {
    .#{$name}-bottom-xs {
      border-end-start-radius: #{$value};
      border-end-end-radius: #{$value};     
    }
  }
  
  @each $name, $value in $border-radius {
    .#{$name}-start-xs {
      border-start-start-radius: #{$value};
      border-end-start-radius: #{$value};   
    }
  }
  
  @each $name, $value in $border-radius {
    .#{$name}-end-xs {
      border-start-end-radius: #{$value};
      border-end-end-radius: #{$value};    
    }
  }
}

// XXS
@mixin border-radius-xxs-css {
  @each $name, $value in $border-radius {
    .#{$name}-xxs {
      border-radius: #{$value};        
    }
  }
  
  @each $name, $value in $border-radius-circle {
    .#{$name}-xxs {
      border-radius: #{$value};        
    }
  }
  
  @each $name, $value in $border-radius {
    .#{$name}-top-xxs {
      border-start-start-radius: #{$value};
      border-start-end-radius: #{$value};     
    }
  }
  
  @each $name, $value in $border-radius {
    .#{$name}-bottom-xxs {
      border-end-start-radius: #{$value};
      border-end-end-radius: #{$value};     
    }
  }
  
  @each $name, $value in $border-radius {
    .#{$name}-start-xxs {
      border-start-start-radius: #{$value};
      border-end-start-radius: #{$value};   
    }
  }
  
  @each $name, $value in $border-radius {
    .#{$name}-end-xxs {
      border-start-end-radius: #{$value};
      border-end-end-radius: #{$value};    
    }
  }
}