Borders

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:

html

Subtractive

Or remove borders:

html

Color

Border utilities like .border-* that generated from our original $theme-colors Sass map don’t yet respond to color modes, however, any .border-*-subtle utility will. This will be resolved in v6.

Change the border color using utilities built on our theme colors.

html

Or modify the default border-color of a component:

Dangerous heading
Changing border color and width
html

Opacity

Added in v5.2.0

Bootstrap border-{color} utilities are generated with Sass using CSS variables. This allows for real-time color changes without compilation and dynamic alpha transparency changes.

How it works

Consider our default .border-success utility.

css

We use an RGB version of our --bs-success (with the value of 25, 135, 84) CSS variable and attached a second CSS variable, --bs-border-opacity, for the alpha transparency (with a default value 1 thanks to a local CSS variable). That means anytime you use .border-success now, your computed color value is rgba(25, 135, 84, 1). The local CSS variable inside each .border-* class avoids inheritance issues so nested instances of the utilities don’t automatically have a modified alpha transparency.

Example

To change that opacity, override --bs-border-opacity via custom styles or inline styles.

This is default success border
This is 50% opacity success border
html

Or, choose from any of the .border-opacity utilities:

This is default success border
This is 75% opacity success border
This is 50% opacity success border
This is 25% opacity success border
This is 10% opacity success border
html

Width

html

Radius

Add classes to an element to easily round its corners.

Example rounded image75x75Example top rounded image75x75Example right rounded image75x75Example bottom rounded image75x75Example left rounded image75x75
html

Sizes

Use the scaling classes for larger or smaller rounded corners. Sizes range from 0 to 5 including circle and pill, and can be configured by modifying the utilities API.

Example non-rounded image75x75Example small rounded image75x75Example default rounded image75x75Example large rounded image75x75Example larger rounded image75x75Example extra large rounded image75x75Completely round image75x75Rounded pill image150x75
html
Example small rounded image75x75Example default left rounded image75x75Example right completely round image75x75Example left rounded pill image75x75Example extra large bottom rounded image75x75
html

CSS

Variables

Added in v5.2.0

Sass variables

Variables for setting border-color in .border-*-subtle utilities in light and dark mode:

Sass maps

Color mode adaptive border colors are also available as a Sass map:

Sass mixins

Sass utilities API

Border utilities are declared in our utilities API in scss/_utilities.scss. Learn how to use the utilities API.