Bootstrap 5 Classes

Article Image

Find out almost all the classes available in Bootstrap 5.

Raul Cano on July 8, 2024

Summary for almost all the classes available in Bootstrap 5. This will help you to quickly find the class you need for your project.

Index

  1. Display Classes
  2. Position Classes
  3. Border Classes
  4. Color
  5. Visibility Classes
  6. Form Classes
  7. Navbar Classes
  8. Grid Classes
  9. Shadow Classes

Classes and Values in Rem

Values in Rem (approximate)

ClassValue in Rem
.-10.25 rem
.-20.5 rem
.-31 rem
.-41.5 rem
.-53 rem
.-autoAutomatic (Centered)

Example: .mx-4 = 1.5 rem

Margin Classes

ClassDescription
mApplies margin to all four sides of the element.
mtApplies margin to the top of the element.
mbApplies margin to the bottom of the element.
msApplies margin to the left side of the element.
meApplies margin to the right side of the element.
mxApplies margin to the left and right sides of the element.
myApplies margin to the top and bottom of the element.
m-autoCenters the element horizontally and applies automatic margin.
mt-autoCenters the element vertically at the top and applies automatic margin to the sides.
mb-autoCenters the element vertically at the bottom and applies automatic margin to the sides.
ml-autoCenters the element horizontally on the left side and applies automatic margin to the top and bottom.
mr-autoCenters the element horizontally on the right side and applies automatic margin to the top and bottom.

Multiple Elements inside a div

ClassDescription
vstack gap-3Spaces above and below
hstack gap-4Elements aligned side by side

Padding Classes

ClassDescription
pApplies padding to all four sides of the element.
ptApplies padding to the top of the element.
pbApplies padding to the bottom of the element.
psApplies padding to the left side of the element.
peApplies padding to the right side of the element.
pxApplies padding to the left and right sides of the element.
pyApplies padding to the top and bottom of the element.
p-0Removes all padding from the element.
p-1Applies a small padding to the element.
p-2Applies moderate padding to the element.
p-3Applies larger padding to the element.
p-4Applies very large padding to the element.
p-5Applies extremely large padding to the element.
p-autoApplies automatic padding to the element.
pt-autoApplies automatic padding to the top of the element.
pb-autoApplies automatic padding to the bottom of the element.
pl-autoApplies automatic padding to the left side of the element.
pr-autoApplies automatic padding to the right side of the element.
px-autoApplies automatic padding to the left and right sides of the element.
py-autoApplies automatic padding to the top and bottom of the element.

Width Classes

ClassDescription
.w-25Sets the width of the element to 25%.
.w-50Sets the width of the element to 50%.
.w-75Sets the width of the element to 75%.
.w-100Sets the width of the element to 100%.
.mw-100Sets the maximum width of the element to 100%.

Height Classes

ClassDescription
.h-25Sets the height of the element to 25%.
.h-50Sets the height of the element to 50%.
.h-75Sets the height of the element to 75%.
.h-100Sets the height of the element to 100%.
.mh-100Sets the maximum height of the element to 100%.

Button Classes

ClassDescription
.btnApplies basic button styles.
.btn-primaryApplies primary button styles.
.btn-secondaryApplies secondary button styles.
.btn-successApplies success button styles.
.btn-dangerApplies danger button styles.
.btn-warningApplies warning button styles.
.btn-infoApplies info button styles.
.btn-lgDefines large button styles.
.btn-smDefines small button styles.
.btn-blockDefines block-level button styles.
.btn-outline-primaryCreates outline button with primary color.
.btn-outline-secondaryCreates outline button with secondary color.
.btn-outline-successCreates outline button with success color.
.btn-outline-dangerCreates outline button with danger color.
.btn-outline-warningCreates outline button with warning color.
.btn-outline-infoCreates outline button with info color.
.btn-linkCreates a button with link style without button appearance.

Icon Classes

ClassDescription
.biAdds icons using Bootstrap Icons.
.fasAdds icons using Font Awesome Solid.
.farAdds icons using Font Awesome Regular.
.fabAdds icons using Font Awesome Brands.
.fa-*Specifies a particular icon (replace * with the icon name). For example, .fa-home for a home icon.

Display Classes

ClassDescription
.d-noneHides the element.
.d-inlineMakes the element inline.
.d-inline-blockMakes the element inline but allows width and height adjustments.
.d-blockMakes the element a block.
.d-tableMakes the element a table.
.d-table-cellMakes the element a table cell.
.d-flexCreates a flex container.
.d-inline-flexCreates an inline flex container.
.d-sm-noneHides the element on small screens.
.d-md-noneHides the element on medium screens.
.d-lg-noneHides the element on large screens.
.d-xl-noneHides the element on extra large screens.

Position Classes

ClassDescription
.position-staticPositions the element statically (default).
.position-relativePositions the element relative to its normal position.
.position-absolutePositions the element absolutely relative to the nearest positioned ancestor.
.position-fixedPositions the element fixed relative to the browser window.
.position-stickyPositions the element sticky based on the user’s scroll position.
.fixed-topFixes the element at the top of the window.
.fixed-bottomFixes the element at the bottom of the window.
.sticky-topFixes the element at the top of the window when the user scrolls down.

Border Classes

ClassDescription
.borderAdds a border to an element.
.border-topAdds a border to the top side of an element.
.border-rightAdds a border to the right side of an element.
.border-bottomAdds a border to the bottom side of an element.
.border-leftAdds a border to the left side of an element.
.border-0Removes the border from an element.
.roundedAdds rounded borders to an element.
.rounded-topAdds rounded borders to the top side of an element.
.rounded-rightAdds rounded borders to the right side of an element.
.rounded-bottomAdds rounded borders to the bottom side of an element.
.rounded-leftAdds rounded borders to the left side of an element.

Color

Text Color Classes

ClassDescription
.text-primaryPrimary text color (blue).
.text-secondarySecondary text color (gray).
.text-successSuccess text color (green).
.text-dangerDanger text color (red).
.text-warningWarning text color (yellow).
.text-infoInfo text color (light blue).
.text-lightLight text color (white).
.text-darkDark text color (black).

Background Color Classes

ClassDescription
.bg-primaryPrimary background color (blue).
.bg-secondarySecondary background color (gray).
.bg-successSuccess background color (green).
.bg-dangerDanger background color (red).
.bg-warningWarning background color (yellow).
.bg-infoInfo background color (light blue).
.bg-lightLight background color (white).
.bg-darkDark background color (black).

Visibility Classes

ClassDescription
.invisibleMakes the element invisible but still occupies space.
.visibleMakes the element visible.

Form Classes

ClassDescription
.form-controlApplies styles to form input elements, such as text fields.
.form-checkApplies styles to checkable elements, such as checkboxes and radio buttons.
.form-groupGroups form elements and adds spacing between them.
.form-inlineCreates an inline form to align elements horizontally.
.form-horizontalCreates a horizontal form to align elements in a label-field layout.
ClassDescription
.navbarApplies basic styles to a navigation bar.
.navbar-expand-lgControls when the navigation bar collapses on large devices.
.navbar-expand-mdControls when the navigation bar collapses on medium devices.
.navbar-expand-smControls when the navigation bar collapses on small devices.
.navbar-lightControls the light color scheme of the navigation bar.
.navbar-darkControls the dark color scheme of the navigation bar.
.navbar-brandStyles the brand logo or name in the navigation bar.

Grid Classes

ClassDescription
.containerCreates a fixed container centered on the page.
.container-fluidCreates a full-width container.
.rowCreates a row for grid elements.
.col-*Defines the number of columns an element will occupy in a row (replace * with a number from 1 to 12).
.offset-*Offsets an element by a specified number of columns (replace * with a number from 1 to 11).

Shadow Classes

ClassDescription
.shadowAdds a soft shadow.
.shadow-lgAdds a large shadow for a more pronounced effect.
.shadow-smAdds a small shadow for a subtle effect.
.shadow-noneRemoves the shadow from the element.