Border, border-radius, border-color, and border-width utilities with opacity support.
Border
Border utilities add or remove element borders using border-{side} class patterns.
Additive
These classes add borders to elements by side.
<span class="border"></span>
<span class="border-top"></span>
<span class="border-end"></span>
<span class="border-bottom"></span>
<span class="border-start"></span>Subtractive
The -0 classes remove the border of an element, on all sides or on one side.
<span class="border border-0"></span>
<span class="border border-top-0"></span>
<span class="border border-end-0"></span>
<span class="border border-bottom-0"></span>
<span class="border border-start-0"></span>Color
Border color utilities map to the Chassis context color palette.
<span class="border default-border-main"></span>
<span class="border default-border-subtle"></span>
<span class="border alternate-border-main"></span>
<span class="border alternate-border-subtle"></span>
<span class="border primary-border-main"></span>
<span class="border primary-border-subtle"></span>
<span class="border secondary-border-main"></span>
<span class="border secondary-border-subtle"></span>
<span class="border neutral-border-main"></span>
<span class="border neutral-border-subtle"></span>
<span class="border danger-border-main"></span>
<span class="border danger-border-subtle"></span>
<span class="border success-border-main"></span>
<span class="border success-border-subtle"></span>
<span class="border warning-border-main"></span>
<span class="border warning-border-subtle"></span>
<span class="border info-border-main"></span>
<span class="border info-border-subtle"></span>
<span class="border black-border-main"></span>
<span class="border black-border-subtle"></span>
<span class="border white-border-main"></span>
<span class="border white-border-subtle"></span>Border color utilities can also override the default border on existing components:
<div class="mb-lg">
<label for="exampleFormControlInput1" class="form-label">Email address</label>
<input type="email" class="form-input border-success" id="exampleFormControlInput1" placeholder="name@example.com">
</div>
<div class="font-h4 pb-xs mb-lg fg-danger border-bottom border-danger">
Dangerous heading
</div>
<div class="p-xs bg-info bg-opacity-10 border border-info border-start-0 rounded-end">
Changing border color and width
</div>Opacity
Opacity utilities control the alpha channel of a context border color through the --cx-border-opacity custom property.
How it works
Each .border-{context} class writes an OKLCH relative color expression into --cx-border-color, using --cx-border-opacity as the alpha channel. A shared selector applies border-color: var(--cx-border-color). --cx-border-opacity defaults to 1.
.border-primary {
--cx-border-color: oklch(from var(--cx-primary) l c h / var(--cx-border-opacity, 1));
}
/* shared selector */
.border-primary, .border-secondary, /* … */ {
border-color: var(--cx-border-color);
}
.border-opacity-50 {
--cx-border-opacity: var(--cx-opacity-50);
}Opacity override
Override --cx-border-opacity with an inline style or a .border-opacity-* utility.
<div class="border border-primary p-2xs mb-sm">This is default primary border</div>
<div class="border border-primary p-2xs" style="--cx-border-opacity: .5;">This is 50% opacity primary border</div>Or, choose from any of the .border-opacity-* utilities:
This is -opacity-solid- primary border
This is -opacity-95- primary border
This is -opacity-90- primary border
This is -opacity-80- primary border
This is -opacity-70- primary border
This is -opacity-60- primary border
This is -opacity-50- primary border
This is -opacity-40- primary border
This is -opacity-30- primary border
This is -opacity-20- primary border
This is -opacity-10- primary border
This is -opacity-05- primary border
This is -opacity-zero- primary border
<p class="border border-primary border-opacity-solid p-2xs">This is -opacity-solid- primary border</p>
<p class="border border-primary border-opacity-95 p-2xs">This is -opacity-95- primary border</p>
<p class="border border-primary border-opacity-90 p-2xs">This is -opacity-90- primary border</p>
<p class="border border-primary border-opacity-80 p-2xs">This is -opacity-80- primary border</p>
<p class="border border-primary border-opacity-70 p-2xs">This is -opacity-70- primary border</p>
<p class="border border-primary border-opacity-60 p-2xs">This is -opacity-60- primary border</p>
<p class="border border-primary border-opacity-50 p-2xs">This is -opacity-50- primary border</p>
<p class="border border-primary border-opacity-40 p-2xs">This is -opacity-40- primary border</p>
<p class="border border-primary border-opacity-30 p-2xs">This is -opacity-30- primary border</p>
<p class="border border-primary border-opacity-20 p-2xs">This is -opacity-20- primary border</p>
<p class="border border-primary border-opacity-10 p-2xs">This is -opacity-10- primary border</p>
<p class="border border-primary border-opacity-05 p-2xs">This is -opacity-05- primary border</p>
<p class="border border-primary border-opacity-zero p-2xs">This is -opacity-zero- primary border</p>Context border opacity
.border-opacity-main and .border-opacity-subtle apply the two border opacity levels of the design tokens to any context border color.
base-color primary bordercx-border-main opacity primary bordercx-border-subtle opacity primary border<div class="border border-primary p-2xs mb-sm">This is <code>base-color</code> primary border</div>
<div class="border border-primary border-opacity-main p-2xs mb-sm">This is <code>cx-border-main</code> opacity primary border</div>
<div class="border border-primary border-opacity-subtle p-2xs mb-sm">This is <code>cx-border-subtle</code> opacity primary border</div>Width
Border width utilities set border-width using the design token scale.
<span class="border border-sm"></span>
<span class="border border-md"></span>
<span class="border border-lg"></span>
<span class="border border-xl"></span>
<span class="border border-2xl"></span><span class="border-bottom border-lg"></span>
<span class="border-start border-xl"></span>Style
Border style utilities set border-style: .border-style-solid, .border-style-dashed and .border-style-none.
<span class="border border-style-solid"></span>
<span class="border border-style-dashed"></span>
<span class="border border-style-none"></span>Inherit
.border-style-inherit sets border-style: inherit, so the element takes the border style of its parent element. This is how a component follows the style of the container it sits in; without the class, a component takes its style from --cx-border-style, which $border-style sets on :root.
<div class="border border-style-dashed p-md">
<div class="card border-style-inherit">
<div class="card-body">Dashed, as its parent</div>
</div>
</div>The style comes from the parent element only, not from a further ancestor: a parent that draws no border has the style none, and the class removes the border of the element.
Radius
Radius utilities round the corners of an element. .rounded applies the radius of --cx-border-radius, and the side classes round the two corners of one side.
<img src="..." class="rounded" alt="...">
<img src="..." class="rounded-top" alt="...">
<img src="..." class="rounded-end" alt="...">
<img src="..." class="rounded-bottom" alt="...">
<img src="..." class="rounded-start" alt="...">Sizes
Border-radius utilities apply rounded corners using the design token scale. Values range from zero (no rounding) through 2xl and 3xl, plus full and circle.
<img src="..." class="rounded-zero" alt="...">
<img src="..." class="rounded-xs" alt="...">
<img src="..." class="rounded-sm" alt="...">
<img src="..." class="rounded-md" alt="...">
<img src="..." class="rounded-lg" alt="...">
<img src="..." class="rounded-xl" alt="...">
<img src="..." class="rounded-2xl" alt="...">
<img src="..." class="rounded-3xl" alt="...">
<img src="..." class="rounded-full" alt="...">
<img src="..." class="rounded-full" alt="...">A radius class sets border-radius only, so on a component it rounds the outside alone: the header and footer of a card keep their inner corners. To round a component inside and out, set its radius through its own custom property, such as --cx-card-border-radius. The inner corners of card, accordion and popover follow it.
<div class="card" style="--cx-card-border-radius: var(--cx-border-radius-2xl)">
<div class="card-header">Header</div>
<div class="card-body">Body</div>
<div class="card-footer">Footer</div>
</div><img src="..." class="rounded-bottom-xs" alt="...">
<img src="..." class="rounded-start-md" alt="...">
<img src="..." class="rounded-end-circle" alt="...">
<img src="..." class="rounded-start-full" alt="...">
<img src="..." class="rounded-2xl rounded-top-zero" alt="...">CSS
Border utilities are generated from Sass maps built on design token values via the utilities API.
Reference
The table lists all border utilities and their CSS properties.
| Class | Properties |
|---|---|
.border | border: var(--cx-border-width) var(--cx-border-style) var(--cx-border-color); |
.border-0 | border: 0; |
.border-top | border-block-start: var(--cx-border-width) var(--cx-border-style) var(--cx-border-color); |
.border-top-0 | border-block-start: 0; |
.border-end | border-inline-end: var(--cx-border-width) var(--cx-border-style) var(--cx-border-color); |
.border-end-0 | border-inline-end: 0; |
.border-bottom | border-block-end: var(--cx-border-width) var(--cx-border-style) var(--cx-border-color); |
.border-bottom-0 | border-block-end: 0; |
.border-start | border-inline-start: var(--cx-border-width) var(--cx-border-style) var(--cx-border-color); |
.border-start-0 | border-inline-start: 0; |
.border-default | --cx-border-color: oklch(from var(--cx-default) l c h / var(--cx-border-opacity, 1)); |
.border-alternate | --cx-border-color: oklch(from var(--cx-alternate) l c h / var(--cx-border-opacity, 1)); |
.border-primary | --cx-border-color: oklch(from var(--cx-primary) l c h / var(--cx-border-opacity, 1)); |
.border-secondary | --cx-border-color: oklch(from var(--cx-secondary) l c h / var(--cx-border-opacity, 1)); |
.border-neutral | --cx-border-color: oklch(from var(--cx-neutral) l c h / var(--cx-border-opacity, 1)); |
.border-warning | --cx-border-color: oklch(from var(--cx-warning) l c h / var(--cx-border-opacity, 1)); |
.border-success | --cx-border-color: oklch(from var(--cx-success) l c h / var(--cx-border-opacity, 1)); |
.border-danger | --cx-border-color: oklch(from var(--cx-danger) l c h / var(--cx-border-opacity, 1)); |
.border-info | --cx-border-color: oklch(from var(--cx-info) l c h / var(--cx-border-opacity, 1)); |
.border-black | --cx-border-color: oklch(from var(--cx-black) l c h / var(--cx-border-opacity, 1)); |
.border-white | --cx-border-color: oklch(from var(--cx-white) l c h / var(--cx-border-opacity, 1)); |
.default-border-main | --cx-border-color: var(--cx-default-border-main); |
.alternate-border-main | --cx-border-color: var(--cx-alternate-border-main); |
.primary-border-main | --cx-border-color: var(--cx-primary-border-main); |
.secondary-border-main | --cx-border-color: var(--cx-secondary-border-main); |
.neutral-border-main | --cx-border-color: var(--cx-neutral-border-main); |
.danger-border-main | --cx-border-color: var(--cx-danger-border-main); |
.success-border-main | --cx-border-color: var(--cx-success-border-main); |
.warning-border-main | --cx-border-color: var(--cx-warning-border-main); |
.info-border-main | --cx-border-color: var(--cx-info-border-main); |
.black-border-main | --cx-border-color: var(--cx-black-border-main); |
.white-border-main | --cx-border-color: var(--cx-white-border-main); |
.default-border-subtle | --cx-border-color: var(--cx-default-border-subtle); |
.alternate-border-subtle | --cx-border-color: var(--cx-alternate-border-subtle); |
.primary-border-subtle | --cx-border-color: var(--cx-primary-border-subtle); |
.secondary-border-subtle | --cx-border-color: var(--cx-secondary-border-subtle); |
.neutral-border-subtle | --cx-border-color: var(--cx-neutral-border-subtle); |
.danger-border-subtle | --cx-border-color: var(--cx-danger-border-subtle); |
.success-border-subtle | --cx-border-color: var(--cx-success-border-subtle); |
.warning-border-subtle | --cx-border-color: var(--cx-warning-border-subtle); |
.info-border-subtle | --cx-border-color: var(--cx-info-border-subtle); |
.black-border-subtle | --cx-border-color: var(--cx-black-border-subtle); |
.white-border-subtle | --cx-border-color: var(--cx-white-border-subtle); |
.border-main | --cx-border-color: var(--cx-border-main); |
.border-subtle | --cx-border-color: var(--cx-border-subtle); |
.border-transparent | --cx-border-color: transparent; |
.border-reset | --cx-border-color: inherit; |
.border-zero | border-width: var(--cx-border-width-zero); |
.border-sm | border-width: var(--cx-border-width-sm); |
.border-md | border-width: var(--cx-border-width-md); |
.border-lg | border-width: var(--cx-border-width-lg); |
.border-xl | border-width: var(--cx-border-width-xl); |
.border-2xl | border-width: var(--cx-border-width-2xl); |
.border-opacity-solid | --cx-border-opacity: var(--cx-opacity-solid); |
.border-opacity-95 | --cx-border-opacity: var(--cx-opacity-95); |
.border-opacity-90 | --cx-border-opacity: var(--cx-opacity-90); |
.border-opacity-80 | --cx-border-opacity: var(--cx-opacity-80); |
.border-opacity-70 | --cx-border-opacity: var(--cx-opacity-70); |
.border-opacity-60 | --cx-border-opacity: var(--cx-opacity-60); |
.border-opacity-50 | --cx-border-opacity: var(--cx-opacity-50); |
.border-opacity-40 | --cx-border-opacity: var(--cx-opacity-40); |
.border-opacity-30 | --cx-border-opacity: var(--cx-opacity-30); |
.border-opacity-20 | --cx-border-opacity: var(--cx-opacity-20); |
.border-opacity-10 | --cx-border-opacity: var(--cx-opacity-10); |
.border-opacity-05 | --cx-border-opacity: var(--cx-opacity-05); |
.border-opacity-zero | --cx-border-opacity: var(--cx-opacity-zero); |
.border-opacity-main | --cx-border-opacity: var(--cx-opacity-border-main); |
.border-opacity-subtle | --cx-border-opacity: var(--cx-opacity-border-subtle); |
.rounded | border-radius: var(--cx-border-radius); |
.rounded-zero | border-radius: var(--cx-border-radius-zero); |
.rounded-xs | border-radius: var(--cx-border-radius-xs); |
.rounded-sm | border-radius: var(--cx-border-radius-sm); |
.rounded-md | border-radius: var(--cx-border-radius-md); |
.rounded-lg | border-radius: var(--cx-border-radius-lg); |
.rounded-xl | border-radius: var(--cx-border-radius-xl); |
.rounded-2xl | border-radius: var(--cx-border-radius-2xl); |
.rounded-3xl | border-radius: var(--cx-border-radius-3xl); |
.rounded-full | border-radius: var(--cx-border-radius-full); |
.rounded-circle | border-radius: var(--cx-border-radius-circle); |
.rounded-top | border-start-start-radius: var(--cx-border-radius); |
.rounded-top-zero | border-start-start-radius: var(--cx-border-radius-zero); |
.rounded-top-xs | border-start-start-radius: var(--cx-border-radius-xs); |
.rounded-top-sm | border-start-start-radius: var(--cx-border-radius-sm); |
.rounded-top-md | border-start-start-radius: var(--cx-border-radius-md); |
.rounded-top-lg | border-start-start-radius: var(--cx-border-radius-lg); |
.rounded-top-xl | border-start-start-radius: var(--cx-border-radius-xl); |
.rounded-top-2xl | border-start-start-radius: var(--cx-border-radius-2xl); |
.rounded-top-3xl | border-start-start-radius: var(--cx-border-radius-3xl); |
.rounded-top-full | border-start-start-radius: var(--cx-border-radius-full); |
.rounded-top-circle | border-start-start-radius: var(--cx-border-radius-circle); |
.rounded-end | border-start-end-radius: var(--cx-border-radius); |
.rounded-end-zero | border-start-end-radius: var(--cx-border-radius-zero); |
.rounded-end-xs | border-start-end-radius: var(--cx-border-radius-xs); |
.rounded-end-sm | border-start-end-radius: var(--cx-border-radius-sm); |
.rounded-end-md | border-start-end-radius: var(--cx-border-radius-md); |
.rounded-end-lg | border-start-end-radius: var(--cx-border-radius-lg); |
.rounded-end-xl | border-start-end-radius: var(--cx-border-radius-xl); |
.rounded-end-2xl | border-start-end-radius: var(--cx-border-radius-2xl); |
.rounded-end-3xl | border-start-end-radius: var(--cx-border-radius-3xl); |
.rounded-end-full | border-start-end-radius: var(--cx-border-radius-full); |
.rounded-end-circle | border-start-end-radius: var(--cx-border-radius-circle); |
.rounded-bottom | border-end-end-radius: var(--cx-border-radius); |
.rounded-bottom-zero | border-end-end-radius: var(--cx-border-radius-zero); |
.rounded-bottom-xs | border-end-end-radius: var(--cx-border-radius-xs); |
.rounded-bottom-sm | border-end-end-radius: var(--cx-border-radius-sm); |
.rounded-bottom-md | border-end-end-radius: var(--cx-border-radius-md); |
.rounded-bottom-lg | border-end-end-radius: var(--cx-border-radius-lg); |
.rounded-bottom-xl | border-end-end-radius: var(--cx-border-radius-xl); |
.rounded-bottom-2xl | border-end-end-radius: var(--cx-border-radius-2xl); |
.rounded-bottom-3xl | border-end-end-radius: var(--cx-border-radius-3xl); |
.rounded-bottom-full | border-end-end-radius: var(--cx-border-radius-full); |
.rounded-bottom-circle | border-end-end-radius: var(--cx-border-radius-circle); |
.rounded-start | border-end-start-radius: var(--cx-border-radius); |
.rounded-start-zero | border-end-start-radius: var(--cx-border-radius-zero); |
.rounded-start-xs | border-end-start-radius: var(--cx-border-radius-xs); |
.rounded-start-sm | border-end-start-radius: var(--cx-border-radius-sm); |
.rounded-start-md | border-end-start-radius: var(--cx-border-radius-md); |
.rounded-start-lg | border-end-start-radius: var(--cx-border-radius-lg); |
.rounded-start-xl | border-end-start-radius: var(--cx-border-radius-xl); |
.rounded-start-2xl | border-end-start-radius: var(--cx-border-radius-2xl); |
.rounded-start-3xl | border-end-start-radius: var(--cx-border-radius-3xl); |
.rounded-start-full | border-end-start-radius: var(--cx-border-radius-full); |
.rounded-start-circle | border-end-start-radius: var(--cx-border-radius-circle); |
.border-style-inherit | border-style: inherit; |
.border-style-none | border-style: none; |
.border-style-solid | border-style: solid; |
.border-style-dashed | border-style: dashed; |
Custom properties
.border and .rounded utilities read their values at runtime from :root custom properties.
--cx-border-width: var(--cx-border-width-md);
--cx-border-style: solid;
--cx-border-color: var(--cx-border-main);
--cx-border-radius: var(--cx-border-radius-md);Sass variables
.border and .rounded utilities compile their defaults from the Sass variables in scss/config/_defaults.scss.
$border-width: var(--border-width-md);
$border-color: var(--border-main);
$border-style: solid;
$border-radius: var(--border-radius-md);Design tokens
Border utilities consume design tokens from Chassis Tokens with the $cx- prefix. — See the design tokens page.
$border-width-zero: $cx-border-width-context-zero;
$border-width-small: $cx-border-width-context-small;
$border-width-medium: $cx-border-width-context-medium;
$border-width-large: $cx-border-width-context-large;
$border-width-xlarge: $cx-border-width-context-xlarge;
$border-width-2xlarge: $cx-border-width-context-2xlarge;$border-radius-zero: $cx-border-radius-context-zero;
$border-radius-xsmall: $cx-border-radius-context-xsmall;
$border-radius-small: $cx-border-radius-context-small;
$border-radius-medium: $cx-border-radius-context-medium;
$border-radius-large: $cx-border-radius-context-large;
$border-radius-xlarge: $cx-border-radius-context-xlarge;
$border-radius-2xlarge: $cx-border-radius-context-2xlarge;
$border-radius-3xlarge: $cx-border-radius-context-3xlarge;
$border-radius-full: $cx-border-radius-context-full;Color tokens are part of the color system in scss/tokens and not listed here.
Sass maps
Border color maps are part of the color system in scss/maps/ and not listed here.
Border width and radius utilities are generated from Sass maps in scss/maps/_borders.scss.
$border-widths: (
zero: $border-width-zero,
sm: $border-width-small,
md: $border-width-medium,
lg: $border-width-large,
xl: $border-width-xlarge,
2xl: $border-width-2xlarge,
);$border-radii: (
zero: $border-radius-zero,
xs: $border-radius-xsmall,
sm: $border-radius-small,
md: $border-radius-medium,
lg: $border-radius-large,
xl: $border-radius-xlarge,
2xl: $border-radius-2xlarge,
3xl: $border-radius-3xlarge,
full: $border-radius-full,
circle: 50%,
);Border opacity utilities are generated from two Sass maps in scss/maps/_opacities.scss.
$opacities defines the full token-named opacity scale for .border-opacity-{level} utilities.
$opacities: (
"solid": $opacity-solid,
"95": $opacity-95,
"90": $opacity-90,
"80": $opacity-80,
"70": $opacity-70,
"60": $opacity-60,
"50": $opacity-50,
"40": $opacity-40,
"30": $opacity-30,
"20": $opacity-20,
"10": $opacity-10,
"05": $opacity-05,
"zero": $opacity-zero,
);$border-opacities defines two semantic border opacity levels.
$border-opacities: (
"main": $opacity-border-main,
"subtle": $opacity-border-subtle,
);Utilities API
Border utilities are declared in scss/utilities/_border.scss using the utilities API.
"border": (
property: border,
values: (
null: var(--border-width) var(--border-style) var(--border-color),
0: 0,
)
),
"border-top": (
class: border-top,
property: border-block-start,
values: (
null: var(--border-width) var(--border-style) var(--border-color),
0: 0,
)
),
"border-end": (
class: border-end,
property: border-inline-end,
values: (
null: var(--border-width) var(--border-style) var(--border-color),
0: 0,
)
),
"border-bottom": (
class: border-bottom,
property: border-block-end,
values: (
null: var(--border-width) var(--border-style) var(--border-color),
0: 0,
)
),
"border-start": (
class: border-start,
property: border-inline-start,
values: (
null: var(--border-width) var(--border-style) var(--border-color),
0: 0,
)
),
"border-color": (
property: (
"border-color": var(--border-color),
"--border-color": null
),
class: null,
group: true,
// values: map-loop($context-colors, opacity-var, #{"$key"}, #{"border"})
values: map-merge-multiple(
map-rename-keys(map-loop($context-colors, opacity-var, #{"$key"}, #{"border"}), "border-", "start"),
map-loop($context-border-colors, varify, #{"$key"}),
map-loop($body-border-colors, varify, #{"$key"}),
( "border-transparent": transparent ),
( "border-reset": inherit )
)
),
"border-width": (
property: border-width,
class: border,
values: map-loop($border-widths, varify, "$key", "border-width")
),
"border-opacity": (
property: --border-opacity,
class: border-opacity,
enabled: $enable-property-opacities,
values: map-merge-multiple(
map-loop($opacities, varify, "$key", "opacity"),
map-loop($border-opacities, varify, "$key", "opacity-border")
)
),"rounded": (
property: border-radius,
class: rounded,
values: map.merge(
(
null: var(--border-radius)
),
map-loop($border-radii, varify, "$key", "border-radius")
)
),
"rounded-top": (
property: border-start-start-radius border-start-end-radius,
class: rounded-top,
values: map.merge(
(
null: var(--border-radius)
),
map-loop($border-radii, varify, "$key", "border-radius")
)
),
"rounded-end": (
property: border-start-end-radius border-end-end-radius,
class: rounded-end,
values: map.merge(
(
null: var(--border-radius)
),
map-loop($border-radii, varify, "$key", "border-radius")
)
),
"rounded-bottom": (
property: border-end-end-radius border-end-start-radius,
class: rounded-bottom,
values: map.merge(
(
null: var(--border-radius)
),
map-loop($border-radii, varify, "$key", "border-radius")
)
),
"rounded-start": (
property: border-end-start-radius border-start-start-radius,
class: rounded-start,
values: map.merge(
(
null: var(--border-radius)
),
map-loop($border-radii, varify, "$key", "border-radius")
)
),