Migrating to v6
Track and review changes to the Bootstrap source files, documentation, and components to help you migrate from v4 to v5.
v6.0.0 Migration
Bootstrap 6 is a major release with many breaking changes to modernize our codebase, adopt newer build tools, and improve customization. Keep reading for a guide on how to migrate from v5 to v6, and a full changelog of what's new.
-
Bump your Bootstrap dependency:
{ "dependencies": { "bootstrap": "^6.0.0" } } -
If using all of Bootstrap's Sass files, include it in your Sass using
@use:@use "bootstrap/scss/bootstrap";With this, you can then easily override Bootstrap's Sass variables and maps:
@use "bootstrap/scss/bootstrap" with ( $spacer: 1rem, $enable-reduced-motion: true, ); -
If using only certain parts of Bootstrap's Sass files, you can use
@useto import them individually. Be aware that our Sass file structure has changed and you may need to adjust your imports accordingly.@use "bootstrap/scss/forms"; -
Update HTML and CSS per the changelog and updates in the documentation.
-
Recompile your Sass to see the changes.
v6.0.0 Changelog
CSS
- Implemented CSS layers in
_root.scssand applied them to all our Sass files.- Layers are set in
_root.scssand then utilized across separate Sass partials. - We cannot, unfortunately, wrap
@useor@forwardstatements in@layer—Sass expects those to be top level at all times. Also, while CSS allows@import "file.css" layer(name), Sass also does not support that.
- Layers are set in
- Clarified and simplified CSS-Sass setup.
- New, streamlined color modes and theming.
- Removed
_maps.scss - Removed
_variables-dark.scss - Added
_colors.scss, splitting them out from_variables.scss, - Added
_theme.scsswhere we setup all our global theming for how colors are applied
- Removed
- Updated lg, xl, and 2xl breakpoints and containers.
- Increased the
lgbreakpoint from 992px to 1024px; it's container remains the same at 960px. - Increased the
xlbreakpoint from 1200px to 1280px, and it's container from 1140px to 1200px. - Renamed
2xlto2xlfor better scaling with additional custom breakpoints - Increased the
2xlbreakpoint from 1400px to 1536px, and it's container from 1320px to 1440px.
- Increased the
Sass
- Dropped support for Node Sass, including no longer testing any of our source CSS against it.
- Rearranged several Sass files in the process.
- Removed
add()andsubtract()functions. Usecalc()instead. - CSS variable prefixing now handled by PostCSS. The
$prefixSass variable has been removed. CSS custom properties are now written without a prefix in the Sass source and prefixed automatically viapostcss-prefix-custom-propertiesduring the build. To customize the prefix, update your PostCSS configuration instead of Sass. - Removes all deprecated Sass variables and values:
- Removed
$nested-kbd-font-weight, no replacement. - Removed
muted,black-50, andwhite-50from text colors utilities map - Consolidated carousel dark variables, removing
$carousel-dark-indicator-active-bg,$carousel-dark-caption-color, and$carousel-dark-control-icon-filterfor their reassigned counterparts. - Removed
$btn-close-white-filterfor$btn-close-filter-dark. - Removed
$border-radius-2xl, use$border-radius-2xl. - Removed
$text-mutedfor secondary color. - Removed
$hr-bg-colorfor$hr-border-colorand$hr-heightfor$hr-border-width. - Removed unused
$dropdown-header-paddingfor the-x/-ysplit variables. - Removed unused
$accordion-button-focus-border-color. - Removed unused
$tooltip-arrow-color. - Removed unused
$popover-arrow-colorand$popover-arrow-outer-color - Removed unused
$alert-bg-scale,$alert-border-scale, and$alert-color-scale(replaced by theme tokens) - Removed unused
$list-group-item-bg-scaleand$list-group-item-color-scale(replaced by theme tokens)
- Removed
Reboot
- Relocated heading classes (like
.h1) and some type classes (.markand.small) to Reboot from_type.scss. This avoids a dependency in Sass modules and we like to avoid extending selectors in general.
Forms
- Refactor checks, radios, and switches.
- Split apart
_form-check.scssinto separate stylesheets:_checkbox.scss,_radio.scss, and_switch.scss. - Also split apart the documentation pages for checks, radios, and switches.
- Added new CSS variables on each of these components. Side note: we could've shared variables here, but chose not to for simplicity's sake.
- Removed several now unused Sass variables.
- Checkboxes now have a wrapping element and an SVG in the DOM for checked and indeterminate states. Radios and switches do not.
- Revamped layout for checks, radios, and switches with labels (and descriptions). We now have custom elements for layout that include basic flexbox styling.
- Refactored toggle buttons to use a nested input structure. The
.btn-checkclass now goes on the label (not the input), with the input nested inside. This eliminates the need forid/forattributes and uses CSS:has()selector instead of sibling selectors. Example:<label class="btn-check btn-solid theme-primary"><input type="checkbox">Toggle</label>.
- Split apart
- Consolidate
.form-selectinto.form-control.- Removed
.form-select—use.form-controlon<select>elements now. Too much abstraction and duplication at the same time. - Adds new CSS variables on
.form-controlfor easier customization without Sass compilation. .form-controlnow has amin-heightat all times as opposed to just on<textarea>elements. This reduces some CSS for us.
- Removed
Helpers
- Ratio helpers have been moved to utilities.
- Dropped clearfix helper for
.d-flow-rootutility.
Utilities
- Ratio helpers are now powered by the utility API and use simplified values without
calc(). - mdo-do: Need to refactor utilities API if we want to restore the commented out custom ratios.
- Display utilities: added
flow-rootoption for a modern clearfix. - Sizing utilities:
- Renamed
.mh-*/.mw-*to.max-h-*/.max-w-* - Added
.min-h-*and.min-w-*utilities with two default values,0and100% - Added
auto,min-content,max-content, andfit-contenttowidthandheightutilities.
- Renamed
- Flex & Grid utilities:
- Added
.place-itemsand.justify-itemsutilities.
- Added
Docs
- Removed all
AddedInbadges. - Rearranged utilities documentation to break apart larger pages that included groups of utilities. Sizing, spacing, flex, type, and more have been broken out into smaller pages with new sub-group headings in the sidebar.