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 mixins as demonstrated below.

Include both border position and radius:

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

Include them individually:

custom.scss
@use "stylemods/scss" as *;
@include border-position-css;
@include border-radius-css;

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

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

You can include the individual breakpoints as required:

custom.scss
@use "stylemods/scss" as *;
@include borders-css;
@media (width <= 1024px) {
  @include border-radius-md-css;
}
@media (width <= 480px) {
  @include border-position-sm-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.

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;

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

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

@mixin border-position-css {
  @each $name, $value in $border-position {
    .#{$name} {
      #{$value}: $border-default;        
    }
  }
  
  .bd-child * {
    border: $border-default;
  }
}

@mixin border-radius-css {
  @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 border-radius-css

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

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

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

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

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

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

// XXS
@mixin border-position-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};    
    }
  }
}

// Grouped mixins
@mixin borders-css {
  @include border-position-css;
  @include border-radius-css;
}

@mixin borders-xxl-css {
  @include border-position-xxl-css;
  @include border-radius-xxl-css;
}

@mixin borders-xl-css {
  @include border-position-xl-css;
  @include border-radius-xl-css;
}

@mixin borders-lg-css {
  @include border-position-lg-css;
  @include border-radius-lg-css;
}

@mixin borders-md-css {
  @include border-position-md-css;
  @include border-radius-md-css;
}

@mixin borders-sm-css {
  @include border-position-sm-css;
  @include border-radius-sm-css;
}

@mixin borders-xs-css {
  @include border-position-xs-css;
  @include border-radius-xs-css;
}

@mixin borders-xxs-css {
  @include border-position-xxs-css;
  @include border-radius-xxs-css;
}