Borders
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
Borders can be removed per-side on an element that already has a border applied.
<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.
Border color utilities generated from $context-colors do not yet respond to color mode changes. The .border-*-subtle variants do. This will be resolved in a future version.
<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-large">
<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="h4 pb-xsmall mb-large fg-danger border-bottom border-danger">
Dangerous heading
</div>
<div class="p-xsmall bg-info bg-opacity-10 border border-info border-start-0 rounded-end">
Changing border color and width
</div>Opacity
How it works
Border color utilities use CSS relative color syntax, enabling alpha opacity control through the --cx-border-opacity variable. The variable defaults to 1.
.border-primary {
border-color: oklch(from var(--cx-primary) l c h / var(--cx-border-opacity, 1)) !important;
}
.border-opacity-50 {
--cx-border-opacity: var(--cx-opacity-50);
}Opacity override
<div class="border border-primary p-2xsmall mb-small">This is default primary border</div>
<div class="border border-primary p-2xsmall" 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-2xsmall">This is -opacity-solid- primary border</p>
<p class="border border-primary border-opacity-95 p-2xsmall">This is -opacity-95- primary border</p>
<p class="border border-primary border-opacity-90 p-2xsmall">This is -opacity-90- primary border</p>
<p class="border border-primary border-opacity-80 p-2xsmall">This is -opacity-80- primary border</p>
<p class="border border-primary border-opacity-70 p-2xsmall">This is -opacity-70- primary border</p>
<p class="border border-primary border-opacity-60 p-2xsmall">This is -opacity-60- primary border</p>
<p class="border border-primary border-opacity-50 p-2xsmall">This is -opacity-50- primary border</p>
<p class="border border-primary border-opacity-40 p-2xsmall">This is -opacity-40- primary border</p>
<p class="border border-primary border-opacity-30 p-2xsmall">This is -opacity-30- primary border</p>
<p class="border border-primary border-opacity-20 p-2xsmall">This is -opacity-20- primary border</p>
<p class="border border-primary border-opacity-10 p-2xsmall">This is -opacity-10- primary border</p>
<p class="border border-primary border-opacity-05 p-2xsmall">This is -opacity-05- primary border</p>
<p class="border border-primary border-opacity-zero p-2xsmall">This is -opacity-zero- primary border</p>Context border opacity
base-color primary bordercx-border-main opacity primary bordercx-border-subtle opacity primary border<div class="border border-primary p-2xsmall mb-small">This is <code>base-color</code> primary border</div>
<div class="border border-primary border-opacity-main p-2xsmall mb-small">This is <code>cx-border-main</code> opacity primary border</div>
<div class="border border-primary border-opacity-subtle p-2xsmall mb-small">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-small"></span>
<span class="border border-medium"></span>
<span class="border border-large"></span>
<span class="border border-xlarge"></span>
<span class="border border-2xlarge"></span>Radius
<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 2xlarge and 3xlarge, plus circle and pill.
<img src="..." class="rounded-zero" alt="...">
<img src="..." class="rounded-xsmall" alt="...">
<img src="..." class="rounded-small" alt="...">
<img src="..." class="rounded-medium" alt="...">
<img src="..." class="rounded-large" alt="...">
<img src="..." class="rounded-xlarge" alt="...">
<img src="..." class="rounded-2xlarge" alt="...">
<img src="..." class="rounded-3xlarge" alt="...">
<img src="..." class="rounded-full" alt="...">
<img src="..." class="rounded-full" alt="..."><img src="..." class="rounded-bottom-xsmall" alt="...">
<img src="..." class="rounded-start-medium" alt="...">
<img src="..." class="rounded-end-circle" alt="...">
<img src="..." class="rounded-start-pill" alt="...">
<img src="..." class="rounded-2xlarge rounded-top-0" 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-reset | --cx-border-color: inherit; |
.border-zero | border-width: var(--cx-border-width-zero); |
.border-small | border-width: var(--cx-border-width-small); |
.border-medium | border-width: var(--cx-border-width-medium); |
.border-large | border-width: var(--cx-border-width-large); |
.border-xlarge | border-width: var(--cx-border-width-xlarge); |
.border-2xlarge | border-width: var(--cx-border-width-2xlarge); |
.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-xsmall | border-radius: var(--cx-border-radius-xsmall); |
.rounded-small | border-radius: var(--cx-border-radius-small); |
.rounded-medium | border-radius: var(--cx-border-radius-medium); |
.rounded-large | border-radius: var(--cx-border-radius-large); |
.rounded-xlarge | border-radius: var(--cx-border-radius-xlarge); |
.rounded-2xlarge | border-radius: var(--cx-border-radius-2xlarge); |
.rounded-3xlarge | border-radius: var(--cx-border-radius-3xlarge); |
.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-xsmall | border-start-start-radius: var(--cx-border-radius-xsmall); |
.rounded-top-small | border-start-start-radius: var(--cx-border-radius-small); |
.rounded-top-medium | border-start-start-radius: var(--cx-border-radius-medium); |
.rounded-top-large | border-start-start-radius: var(--cx-border-radius-large); |
.rounded-top-xlarge | border-start-start-radius: var(--cx-border-radius-xlarge); |
.rounded-top-2xlarge | border-start-start-radius: var(--cx-border-radius-2xlarge); |
.rounded-top-3xlarge | border-start-start-radius: var(--cx-border-radius-3xlarge); |
.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-xsmall | border-start-end-radius: var(--cx-border-radius-xsmall); |
.rounded-end-small | border-start-end-radius: var(--cx-border-radius-small); |
.rounded-end-medium | border-start-end-radius: var(--cx-border-radius-medium); |
.rounded-end-large | border-start-end-radius: var(--cx-border-radius-large); |
.rounded-end-xlarge | border-start-end-radius: var(--cx-border-radius-xlarge); |
.rounded-end-2xlarge | border-start-end-radius: var(--cx-border-radius-2xlarge); |
.rounded-end-3xlarge | border-start-end-radius: var(--cx-border-radius-3xlarge); |
.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-xsmall | border-end-end-radius: var(--cx-border-radius-xsmall); |
.rounded-bottom-small | border-end-end-radius: var(--cx-border-radius-small); |
.rounded-bottom-medium | border-end-end-radius: var(--cx-border-radius-medium); |
.rounded-bottom-large | border-end-end-radius: var(--cx-border-radius-large); |
.rounded-bottom-xlarge | border-end-end-radius: var(--cx-border-radius-xlarge); |
.rounded-bottom-2xlarge | border-end-end-radius: var(--cx-border-radius-2xlarge); |
.rounded-bottom-3xlarge | border-end-end-radius: var(--cx-border-radius-3xlarge); |
.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-xsmall | border-end-start-radius: var(--cx-border-radius-xsmall); |
.rounded-start-small | border-end-start-radius: var(--cx-border-radius-small); |
.rounded-start-medium | border-end-start-radius: var(--cx-border-radius-medium); |
.rounded-start-large | border-end-start-radius: var(--cx-border-radius-large); |
.rounded-start-xlarge | border-end-start-radius: var(--cx-border-radius-xlarge); |
.rounded-start-2xlarge | border-end-start-radius: var(--cx-border-radius-2xlarge); |
.rounded-start-3xlarge | border-end-start-radius: var(--cx-border-radius-3xlarge); |
.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-medium);
--cx-border-style: solid;
--cx-border-color: var(--cx-border-main);
--cx-border-radius: var(--cx-border-radius-medium);Sass variables
.border and .rounded utilities compile their defaults from the Sass variables in scss/config/_defaults.scss.
$border-width: var(--border-width-medium);
$border-color: var(--border-main);
$border-style: solid;
$border-radius: var(--border-radius-medium);Design tokens
Border utilities consume design tokens from Chassis Tokens with the $cx- prefix. — See thedesign 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,
small: $border-width-small,
medium: $border-width-medium,
large: $border-width-large,
xlarge: $border-width-xlarge,
2xlarge: $border-width-2xlarge,
);$border-radii: (
zero: $border-radius-zero,
xsmall: $border-radius-xsmall,
small: $border-radius-small,
medium: $border-radius-medium,
large: $border-radius-large,
xlarge: $border-radius-xlarge,
2xlarge: $border-radius-2xlarge,
3xlarge: $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-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")
)
),