Border
Source: https://getbootstrap.com/docs/6.0/utilities/border
Use border utilities to quickly style the border and border-radius of an element. Great for images, buttons, or any other element.
Border
Use border utilities to add or remove an element’s borders. Choose from all borders or one at a time.
Additive
Add borders to custom elements:
<Example class="bd-example-border-utils" code={<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
Or remove borders:
<Example class="bd-example-border-utils" code={<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>} />
Width
Border width utilities are available in increments of 1px from 0 to 5px. These set border-width on all sides.
<Example class="bd-example-border-utils" code={<span class="border border-keyline"></span>
<span class="border border-1"></span>
<span class="border border-2"></span>
<span class="border border-3"></span>
<span class="border border-4"></span>
<span class="border border-5"></span>} />
Per-side widths
We do not ship per-side border width utilities. Combine a side utility with a width utility when one side needs a thicker border:
<Example class="bd-example-border-utils" code={<span class="border-top border-2"></span>
<span class="border-end border-3"></span>
<span class="border-bottom border-4"></span>
<span class="border-start border-5"></span>} />
Extend utilities
Extend the border classes with our utilities API when you need different widths on different sides, without combining classes as shown above. Here‘s an example using the width longhands instead of the border shorthand so values from $border-widths apply cleanly.
// _my-utilities.scss
@use "sass:map";
@use "bootstrap/scss/config" as *;
@use "bootstrap/scss/utilities";
$border-width-values: map.merge($border-widths, (keyline: var(--border-width-keyline)));
$utilities: map.merge(
$utilities,
(
"border-top-width": (
property: border-block-start-width,
class: border-t,
values: $border-width-values
),
"border-end-width": (
property: border-inline-end-width,
class: border-e,
values: $border-width-values
),
"border-bottom-width": (
property: border-block-end-width,
class: border-b,
values: $border-width-values
),
"border-start-width": (
property: border-inline-start-width,
class: border-s,
values: $border-width-values
)
)
);
Load that partial before Bootstrap:
// my-bootstrap.scss
@use "my-utilities";
@use "bootstrap/scss/bootstrap";
This adds classes like .border-t-5, .border-e-5, .border-b-5, and .border-s-5. Pair them with .border or a side utility such as .border-bottom so the border still has a style and color.
CSS
Variables
Sass variables
Sass mixins
Sass utilities API
Border utilities are declared in our utilities API in scss/_utilities.scss. Learn how to use the utilities API.
