Bootstrap 5.3 — Complete Reference

All major classes, utilities, and components — use Ctrl+F to find anything
Layout

Breakpoints

NameInfixMin-widthMax-width
Extra smallnone< 576px575.98px
Smallsm≥ 576px767.98px
Mediummd≥ 768px991.98px
Largelg≥ 992px1199.98px
Extra largexl≥ 1200px1399.98px
Extra extra largexxl≥ 1400px

Use breakpoint infixes with classes like col-md-6, d-lg-none, mt-sm-3, etc.

Containers

Classxssmmdlgxlxxl
.container100%540px720px960px1140px1320px
.container-sm100%540px720px960px1140px1320px
.container-md100%100%720px960px1140px1320px
.container-lg100%100%100%960px1140px1320px
.container-xl100%100%100%100%1140px1320px
.container-xxl100%100%100%100%100%1320px
.container-fluid100%100%100%100%100%100%

Grid System

12-column grid using flexbox. Wrap columns in .row inside a container.

col
col
col
col-4
col-8
col-sm-6 col-md-4
col-sm-6 col-md-4
col-sm-12 col-md-4
Class patternDescription
.colAuto-width, equal columns
.col-{1–12}Explicit column width
.col-{bp}-{1–12}Responsive column width
.col-autoFit content width
.row-cols-{n}Set number of cols per row
.row-cols-{bp}-{n}Responsive cols per row
.offset-{n}Offset column by n
.offset-{bp}-{n}Responsive offset
.order-{0–5} / .order-first / .order-lastColumn ordering

Gutters

ClassDescription
.g-{0–5}Both axis gutters
.gx-{0–5}Horizontal gutters
.gy-{0–5}Vertical gutters
.g-{bp}-{0–5}Responsive gutters

Gutter sizes: 0=0, 1=.25rem, 2=.5rem, 3=1rem, 4=1.5rem, 5=3rem

Flexbox Utilities

ClassCSS
.d-flexdisplay: flex
.d-inline-flexdisplay: inline-flex
.flex-row / .flex-row-reverseflex-direction: row / row-reverse
.flex-column / .flex-column-reverseflex-direction: column / column-reverse
.flex-wrap / .flex-nowrap / .flex-wrap-reverseflex-wrap values
.flex-fillflex: 1 1 auto
.flex-grow-0 / .flex-grow-1flex-grow
.flex-shrink-0 / .flex-shrink-1flex-shrink
.justify-content-start/end/center/between/around/evenlyjustify-content
.align-items-start/end/center/baseline/stretchalign-items
.align-self-start/end/center/baseline/stretch/autoalign-self
.align-content-start/end/center/between/around/stretchalign-content
.order-{0–5} / .order-first / .order-lastorder
.gap-{0–5} / .row-gap-{0–5} / .column-gap-{0–5}gap / row-gap / column-gap

All flex utilities support responsive infixes, e.g. .justify-content-md-center

Content

Typography

h1. Heading small muted

h2. Heading

h3. Heading

h4. Heading

h5. Heading
h6. Heading

Lead paragraph — stands out with .lead

Normal paragraph with highlight, deleted text, inserted text, bold, italic, HTML, citation, Ctrl+S, inline code, sample output.

Underlined.

Strikethrough.

Small text using <small> or .small class

A quote looks like this.

Someone famous in Source Title
ClassEffect
.h1.h6Apply heading styles to any element
.leadLarger, lighter paragraph
.small80% font size
.markHighlight background
.text-mutedMuted text color
.text-truncateTruncate with ellipsis (requires overflow hidden)
.text-breakBreak long words
.font-monospaceMonospace font family
.fw-bold / .fw-semibold / .fw-normal / .fw-lightfont-weight 700 / 600 / 400 / 300
.fst-italic / .fst-normalfont-style
.lh-1 / .lh-sm / .lh-base / .lh-lgline-height: 1 / 1.25 / 1.5 / 2
.fs-1.fs-6Font size (maps to h1–h6 sizes)
.text-decoration-none/underline/line-throughtext-decoration
.text-lowercase / .text-uppercase / .text-capitalizetext-transform
.text-wrap / .text-nowrapwhite-space: normal / nowrap
.text-start / .text-center / .text-endtext-align (support breakpoint infixes)
.text-resetInherit parent color

Display Headings

Display 1

Display 2

Display 3

Display 4

Display 5

Display 6

Classes: .display-1 through .display-6

Images

ClassEffect
.img-fluidmax-width: 100%; height: auto — responsive image
.img-thumbnailRounded border, padding, white bg
.roundedRounded corners
.rounded-circleCircular crop
.float-start / .float-endFloat image left/right

Tables

#NameStatus
1AliceActive
2BobPending
3CarolInactive
ClassEffect
.tableBase table (required)
.table-stripedZebra-striped rows
.table-striped-columnsZebra-striped columns
.table-hoverHover row highlight
.table-borderedBorders on all sides
.table-borderlessNo borders
.table-smHalf padding
.table-responsiveHorizontal scroll wrapper
.table-responsive-{bp}Responsive scroll below breakpoint
.table-{color}Contextual color on <table>, <tr>, <th>, <td>
.table-dark / .table-lightDark/light table variant
.caption-topMove <caption> to top

Contextual colors for rows/cells: .table-primary .table-secondary .table-success .table-danger .table-warning .table-info .table-light .table-dark

Figures

<figure class="figure">
  <img src="..." class="figure-img img-fluid rounded" alt="...">
  <figcaption class="figure-caption text-end">Caption here.</figcaption>
</figure>
Forms

Form Controls

We'll never share your email.
ClassEffect
.form-labelLabel styling (margin-bottom)
.form-controlText input, textarea, file input styling
.form-control-lg / .form-control-smLarge/small size modifier
.form-control-plaintextReadonly plain text, no border/bg
.form-textHelp text below input

Select

Classes: .form-select, .form-select-lg, .form-select-sm

Checks & Radios




ClassEffect
.form-checkWrapper for checkbox/radio
.form-check-inputThe input element
.form-check-labelThe label element
.form-check-inlineInline (side-by-side)
.form-switchToggle switch style (add to .form-check wrapper)
.btn-checkVisually hidden input for button-style toggle

Range

Class: .form-range

Input Groups

@
.00 USD
$
Large
Small

Wrapper: .input-group — Sizes: .input-group-sm / .input-group-lg — Addon: .input-group-text

Floating Labels

Wrapper: .form-floating — The placeholder attribute is required on the input.

Validation

Looks good!
Please provide a valid value.
Must agree!
Class / AttributeEffect
.is-valid / .is-invalidManual validation state on input
.valid-feedback / .invalid-feedbackShown message block
.valid-tooltip / .invalid-tooltipTooltip-style feedback (parent needs position:relative)
.was-validated on <form>Browser native validation display
Components

Alerts

Alert with a link inside.

Base: .alert .alert-{color} — Dismissible: add .alert-dismissible .fade .show and data-bs-dismiss="alert" on button — Link: .alert-link

Badges

Primary Secondary Success Danger Warning Info Light Dark

Pill Primary Pill Success

Base: .badge .bg-{color} — Pill: add .rounded-pill

Buttons







Link button
ClassEffect
.btnBase button (required)
.btn-{color}Solid filled button
.btn-outline-{color}Outline button
.btn-lg / .btn-smSize variants
.activeActive/pressed state
disabled attributeDisabled state
.btn-close× close button (no text)

Button Groups


 
 

Wrappers: .btn-group / .btn-group-vertical — Sizes: .btn-group-sm / .btn-group-lg

Cards

Card Header
Card Title
Card Subtitle

Some quick example text.

Go somewhere
Primary Card

With text-bg-primary utility.

Border Colored

border-success class.

Card with list group inside:

  • Item 1
  • Item 2
ClassEffect
.cardCard container
.card-bodyMain content area (padding)
.card-title / .card-subtitleTitle/subtitle inside card-body
.card-textParagraph inside card-body
.card-linkLink inside card-body
.card-header / .card-footerTop/bottom sections
.card-img-top / .card-img-bottomImage cap
.card-img-overlayPosition content over image
.text-bg-{color}Colored card with appropriate text
.card-groupFlush/joined card group

Collapse

Toggle via link
Collapsible content. Starts shown (.show).
Attribute / ClassEffect
data-bs-toggle="collapse"On the trigger element
data-bs-target="#id"Target element (button)
href="#id"Target element (link)
.collapseOn the collapsible element
.showInitially expanded
.collapsingAdded during transition (auto)
.accordionAccordion wrapper
.accordion-item / .accordion-header / .accordion-button / .accordion-bodyAccordion parts
data-bs-parent="#accordionId"Close others when one opens

List Group

  • Active item
  • Normal item
  • Disabled item
  • Actionable (hover)
  • With badge 14
  • Horizontal
  • List
  • Group

Contextual colors:

  • Primary
  • Success
  • Danger
  • Warning
ClassEffect
.list-groupWrapper (ul or div)
.list-group-itemEach item
.list-group-item-actionHover/focus states for a/button
.list-group-flushRemove border-radius and outer borders
.list-group-numberedAuto-numbered with CSS counters
.list-group-horizontalHorizontal layout
.list-group-horizontal-{bp}Responsive horizontal
.list-group-item-{color}Contextual color

Offcanvas

Offcanvas Title
Content here. Slides in from the left.
ClassEffect
.offcanvasOffcanvas container
.offcanvas-startSlide from left
.offcanvas-endSlide from right
.offcanvas-topSlide from top
.offcanvas-bottomSlide from bottom
.offcanvas-header / .offcanvas-title / .offcanvas-bodyStructural parts
data-bs-toggle="offcanvas"On trigger
data-bs-scroll="true"Allow body scroll when open
data-bs-backdrop="false"Disable backdrop

Popovers

AttributeEffect
data-bs-toggle="popover"Enable popover
data-bs-title="..."Popover header
data-bs-content="..."Popover body
data-bs-placement="top/bottom/left/right"Direction
data-bs-trigger="hover focus click"Trigger type(s)
data-bs-html="true"Allow HTML in content

JS init (required)

var popoverTriggerList = document.querySelectorAll('[data-bs-toggle="popover"]')
var popoverList = [...popoverTriggerList].map(function(el) { return new bootstrap.Popover(el) })

Progress

25%
50%
75%
ClassEffect
.progressOuter track; set height with style
.progress-barThe fill; set width with style
.progress-bar-stripedStripe pattern
.progress-bar-animatedAnimated stripes
.bg-{color}Bar color

Scrollspy

<!-- On scrollable container: -->
<body data-bs-spy="scroll" data-bs-target="#navbar" data-bs-offset="70" data-bs-smooth-scroll="true">

<!-- Or on a div: -->
<div data-bs-spy="scroll" data-bs-target="#list-example" style="height:200px; overflow-y:scroll">
  <h4 id="s1">Section 1</h4>...
</div>

<!-- Nav must have href matching the section IDs -->
<nav id="list-example">
  <a class="nav-link" href="#s1">Section 1</a>
</nav>

Attributes: data-bs-spy="scroll" on target, data-bs-target="#navId", data-bs-offset (px), data-bs-smooth-scroll="true"

Spinners

Loading...


Border spinner: .spinner-border — Grow spinner: .spinner-grow — Sizes: .spinner-border-sm / .spinner-grow-sm — Colors via .text-{color}

Toasts

<div class="toast-container position-fixed bottom-0 end-0 p-3">
  <div id="myToast" class="toast" role="alert">
    <div class="toast-header">
      <strong class="me-auto">Title</strong>
      <small>Just now</small>
      <button type="button" class="btn-close" data-bs-dismiss="toast"></button>
    </div>
    <div class="toast-body">Message here.</div>
  </div>
</div>
var toastEl = document.getElementById('myToast')
var toast = new bootstrap.Toast(toastEl)
toast.show()
// Options: autohide (true), delay (5000ms)
// data-bs-autohide="false" to keep open

Tooltips

AttributeEffect
data-bs-toggle="tooltip"Mark element
data-bs-title="..."Tooltip text
data-bs-placement="top/bottom/left/right/auto"Direction
data-bs-html="true"HTML in tooltip
data-bs-trigger="hover focus"Trigger event(s)

JS init (required)

var tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]')
var tooltipList = [...tooltipTriggerList].map(function(el) { return new bootstrap.Tooltip(el) })
Utilities

Spacing (Margin & Padding)

Format: .{property}{sides}-{size} — responsive: .{property}{sides}-{bp}-{size}

PropertySidesSize
m = margin
p = padding
blank = all
t = top
b = bottom
s = start (left)
e = end (right)
x = horizontal
y = vertical
0 = 0
1 = .25rem
2 = .5rem
3 = 1rem
4 = 1.5rem
5 = 3rem
auto = auto (margin only)

Examples: .mt-3 (margin-top 1rem), .px-2 (padding-left/right .5rem), .mx-auto (center block), .ms-md-4 (responsive margin-start)

Sizing

ClassCSS
.w-25 / .w-50 / .w-75 / .w-100width: 25% / 50% / 75% / 100%
.w-autowidth: auto
.mw-100max-width: 100%
.vw-100width: 100vw
.min-vw-100min-width: 100vw
.h-25 / .h-50 / .h-75 / .h-100height: 25% / 50% / 75% / 100%
.h-autoheight: auto
.mh-100max-height: 100%
.vh-100height: 100vh
.min-vh-100min-height: 100vh

Display

Format: .d-{value} or .d-{bp}-{value}

ClassCSS
.d-nonedisplay: none
.d-inlinedisplay: inline
.d-inline-blockdisplay: inline-block
.d-blockdisplay: block
.d-griddisplay: grid
.d-inline-griddisplay: inline-grid
.d-tabledisplay: table
.d-table-celldisplay: table-cell
.d-table-rowdisplay: table-row
.d-flexdisplay: flex
.d-inline-flexdisplay: inline-flex
.d-print-{value}Print-only display value

Hide at breakpoint: .d-none .d-md-block (hidden below md) — Show only at sm: .d-sm-block .d-md-none

Position

ClassCSS
.position-staticposition: static
.position-relativeposition: relative
.position-absoluteposition: absolute
.position-fixedposition: fixed
.position-stickyposition: sticky
.sticky-top / .sticky-bottomsticky top/bottom with top:0/bottom:0
.sticky-{bp}-top/bottomResponsive sticky
.fixed-top / .fixed-bottomFixed at top/bottom of viewport
.top-0 / .top-50 / .top-100top: 0 / 50% / 100%
.bottom-0 / .bottom-50 / .bottom-100bottom
.start-0 / .start-50 / .start-100left (LTR) / right (RTL)
.end-0 / .end-50 / .end-100right (LTR) / left (RTL)
.translate-middletransform: translate(-50%, -50%)
.translate-middle-x / .translate-middle-yX or Y only

Centering trick: .position-absolute .top-50 .start-50 .translate-middle

Borders

border border-primary border-success border-danger border-0

border-top border-end border-bottom border-start

border-2 border-3 border-4 border-5

rounded rounded-0 rounded-1 rounded-2 rounded-3 rounded-4 rounded-5 circle pill

rounded-top rounded-bottom rounded-start rounded-end
ClassEffect
.borderAdd 1px border all sides
.border-{0–5}Border width
.border-{color}Border color
.border-top/end/bottom/startSingle side border on
.border-top-0/end-0/bottom-0/start-0Single side border off
.border-opacity-{10/25/50/75/100}Border opacity
.roundedDefault border-radius
.rounded-{0–5}Border-radius scale
.rounded-circle50% border-radius
.rounded-pillPill shape (50rem radius)
.rounded-top/end/bottom/startOne side rounded

Shadows

shadow-none
shadow-sm
shadow (default)
shadow-lg

Classes: .shadow-none / .shadow-sm / .shadow / .shadow-lg

Colors & Backgrounds

text-primary

text-secondary

text-success

text-danger

text-warning

text-info

text-body

text-muted

text-black

text-white



bg-primary
bg-secondary
bg-success
bg-danger
bg-warning
bg-info
bg-light
bg-dark
bg-body
bg-transparent

text-bg-primary (auto contrast)
text-bg-success
text-bg-danger
text-bg-warning

bg-opacity-75
bg-opacity-50
bg-opacity-25
bg-opacity-10
Class patternEffect
.text-{color}Text color (primary/secondary/success/danger/warning/info/light/dark/body/muted/white/black/white-50/black-50)
.text-opacity-{25/50/75/100}Text opacity
.bg-{color}Background color
.bg-opacity-{10/25/50/75/100}Background opacity
.bg-gradientAdd gradient to bg color
.text-bg-{color}Background + auto-contrast text color
.link-{color}Color a link + hover state
.link-opacity-{10/25/50/75/100}Link opacity
.link-underline-{color}Underline color only

Overflow

ClassCSS
.overflow-autooverflow: auto
.overflow-hiddenoverflow: hidden
.overflow-visibleoverflow: visible
.overflow-scrolloverflow: scroll
.overflow-x-auto/hidden/visible/scrolloverflow-x
.overflow-y-auto/hidden/visible/scrolloverflow-y

Visibility & Accessibility

ClassEffect
.visiblevisibility: visible
.invisiblevisibility: hidden (still takes space)
.d-nonedisplay: none (no space)
.visually-hiddenHidden visually but available to screen readers
.visually-hidden-focusableHidden until focused (skip nav)
.stretched-linkMake containing block clickable (extend link)
.clearfixClearfix float hack
.float-start / .float-end / .float-noneFloat utilities (support bp infixes)
.pe-none / .pe-autopointer-events: none / auto
.user-select-none/all/autouser-select

Z-index

Classz-indexUse case
.z-n1-1Behind content
.z-00
.z-11Slightly above
.z-22
.z-33
CSS var --bs-zindex-dropdown1000Dropdowns
CSS var --bs-zindex-sticky1020Sticky elements
CSS var --bs-zindex-fixed1030Fixed navbars
CSS var --bs-zindex-offcanvas-backdrop1040Offcanvas backdrop
CSS var --bs-zindex-offcanvas1045Offcanvas
CSS var --bs-zindex-modal-backdrop1050Modal backdrop
CSS var --bs-zindex-modal1055Modal
CSS var --bs-zindex-popover1070Popovers
CSS var --bs-zindex-tooltip1080Tooltips
CSS var --bs-zindex-toast1090Toasts
JavaScript API

JavaScript API — Common Patterns

CDN include

<!-- Bundle (includes Popper) -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.js"></script>

<!-- Separate: Popper first, then Bootstrap -->
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/umd/popper.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.js"></script>

Universal patterns

// Instantiate
var myComponent = new bootstrap.Modal(el, options)

// Get existing instance (returns null if none)
var instance = bootstrap.Modal.getInstance(el)

// Get or create
var instance = bootstrap.Modal.getOrCreateInstance(el)

// Dispose
instance.dispose()

Component — Options & Events

ComponentKey OptionsKey Events
Modal backdrop (bool/static), keyboard, focus show.bs.modal, shown.bs.modal, hide.bs.modal, hidden.bs.modal
Collapse parent, toggle show.bs.collapse, shown.bs.collapse, hide.bs.collapse, hidden.bs.collapse
Dropdown autoClose (true/false/inside/outside), boundary, display, offset, popperConfig show.bs.dropdown, shown.bs.dropdown, hide.bs.dropdown, hidden.bs.dropdown
Tooltip animation, container, delay, html, placement, selector, title, trigger, offset show.bs.tooltip, shown.bs.tooltip, hide.bs.tooltip, hidden.bs.tooltip
Popover Same as tooltip + content, sanitize, allowList show.bs.popover, shown.bs.popover, hide.bs.popover, hidden.bs.popover
Toast animation, autohide (true), delay (5000) show.bs.toast, shown.bs.toast, hide.bs.toast, hidden.bs.toast
Carousel interval (5000), keyboard, pause (hover), ride (false/carousel), touch, wrap slide.bs.carousel, slid.bs.carousel
Offcanvas backdrop (true/false/static), keyboard, scroll show.bs.offcanvas, shown.bs.offcanvas, hide.bs.offcanvas, hidden.bs.offcanvas
Tab show.bs.tab, shown.bs.tab, hide.bs.tab, hidden.bs.tab
Alert close.bs.alert, closed.bs.alert
Scrollspy offset, method (auto/offset/position), rootMargin, smoothScroll, threshold, target activate.bs.scrollspy

Event listener pattern

var myModalEl = document.getElementById('myModal')
myModalEl.addEventListener('shown.bs.modal', function(event) {
  // do something when fully shown
})

// Event object for carousel has: direction, relatedTarget, from, to
var myCarouselEl = document.getElementById('myCarousel')
myCarouselEl.addEventListener('slid.bs.carousel', function(event) {
  console.log(event.to)
})

data-bs-* attribute reference

AttributeEquivalent JS option
data-bs-toggle="modal"Triggers Modal.show()
data-bs-dismiss="modal|alert|offcanvas"Triggers hide()
data-bs-target="#id"target option
data-bs-interval="3000"Carousel interval option
data-bs-ride="carousel"Carousel ride option
data-bs-backdrop="static"Modal backdrop option
data-bs-keyboard="false"Modal keyboard option
data-bs-config='{...}'JSON options object (v5.2+)
Bootstrap 5.3 Reference — Official Docs