Migration·续3

  • Collapse triggers now use aria-expanded as the state signal. Bootstrap v6 no longer adds or removes a .collapsed class on collapse trigger elements. If you styled or queried trigger state with .collapsed, migrate those selectors to [aria-expanded="false"] and open-state selectors to [aria-expanded="true"].
  • Removed the Collapse toggle option. The constructor now keeps the state your markup declares, instead of flipping it. Drop toggle: false from your config, it is the behavior you already get. If you relied on the old toggle: true default to change the state on init, call the matching method instead.

```js // v5 new bootstrap.Collapse(el) // opened a closed element new bootstrap.Collapse(el, { toggle: false })

// v6 new bootstrap.Collapse(el).show() new bootstrap.Collapse(el) ```

  • Dismiss triggers now find responsive drawers. data-bs-dismiss="drawer" resolves breakpoint-prefixed drawers such as .lg:drawer, so a close button inside a responsive drawer no longer needs data-bs-target. Existing data-bs-target attributes keep working.
  • Toggle buttons get a default aria-pressed. A toggle button needs aria-pressed for assistive technology to announce it as a toggle, so Bootstrap now adds the attribute to every [data-bs-toggle="button"] that lacks it on DOMContentLoaded, reading .active to pick the value. Write aria-pressed="false" in your markup so the state is correct before our JavaScript runs.
  • The navbar no longer computes heights. v5 derived $navbar-brand-height and $navbar-brand-padding-y from the nav link font size, line height, and padding, so the brand matched the links. v6 drops that math. .navbar is a flex container that centers its children, so padding and content set the height. --navbar-brand-padding-y is now .375rem, which matches the nav link block padding, so the brand and the links keep the same click target. A new --navbar-min-height token gives the bar a 3.5rem floor, so a default navbar is 56px high. Taller content, such as a logo, still makes the bar grow past the floor. Set --navbar-padding-y or --navbar-min-height to control the height of the bar.
  • Navbar toggler icon now uses a CSS mask. .navbar-toggler-icon renders via mask-image (--navbar-toggler-icon) tinted with background-color: currentcolor instead of an embedded background-image SVG. The markup stays an empty <span class="navbar-toggler-icon">, but the icon now inherits the current text color (including dark mode), so the separate light/dark toggler SVGs are no longer needed.
  • Rebuilt the carousel on CSS scroll snap. The slide engine no longer uses float + translateX class juggling or a custom swipe handler—.carousel-inner is now a native horizontal scroll-snap container, so sliding, touch dragging, momentum, and keyboard scrolling come from the browser. The markup is unchanged (.carousel → .carousel-inner → .carousel-item), and the public JavaScript API (next, prev, to, cycle, pause) plus the slide.bs.carousel / slid.bs.carousel events are preserved.
  • New capabilities: show multiple slides at once, reveal a “peek” of adjacent slides, gaps, center mode, and variable-width slides—all via CSS custom properties (--carousel-items, --carousel-items-gap, --carousel-items-peek) and the .carousel-center / .carousel-auto variants.
  • Removed transitional classes .carousel-item-start, .carousel-item-end, .carousel-item-next, and .carousel-item-prev, plus the .carousel.pointer-event helper—the browser tracks scroll position instead of an .active layout class. (The active slide still gets .active for styling.)
  • .carousel-fade is now a stacked-opacity (grid) crossfade animated with a CSS opacity transition over --bs-carousel-fade-duration (it collapses to an instant swap under reduced motion).
  • Removed the touch option. Because .carousel-inner is a native scroll-snap container, horizontal touch dragging is part of the browser’s native scrolling and is no longer toggled by JavaScript.
  • Active-slide syncing uses an IntersectionObserver; as a result slid.bs.carousel fires when the new slide settles into view, and a multi-slide to() jump may emit intermediate slid events as it scrolls past.
  • Renamed the carousel ride option to autoplay, and made it a boolean. Autoplay is now strictly opt-in: a carousel only autoplays when autoplay is true (set via data-bs-autoplay="true"). The old ride option and its string "carousel" value have been removed, as has the ride="true" behavior that started autoplaying only after the first user interaction.
  • data-bs-ride="carousel" → data-bs-autoplay="true"
  • data-bs-ride="true" → data-bs-autoplay="true" (it now autoplays on load like any other autoplaying carousel, instead of waiting for the first interaction)
  • JavaScript: new bootstrap.Carousel(el, { ride: 'carousel' }) → new bootstrap.Carousel(el, { autoplay: true })
  • The auto-initialization-on-load selector changed accordingly from [data-bs-ride="carousel"] to [data-bs-autoplay="true"].
  • Autoplaying carousels now stop when the user interacts with them. Clicking a control or indicator, navigating with the keyboard, or swiping permanently stops autoplay instead of resuming it, respecting the visitor’s intent (WCAG 2.2.2). Previously these interactions kept the carousel cycling.
  • New .carousel-control-play-pause control provides a discoverable, accessible button to pause and resume an autoplaying carousel—the mechanism WCAG 2.2.2 requires (a hover-only pause does not qualify). It renders pause/play icons via CSS masks (--carousel-control-pause-icon / --carousel-control-play-icon), swaps its icon and aria-label with state, and can also start autoplay on an otherwise static carousel.
  • Stacked is now the default carousel layout. .carousel is a flex column, so prev/next controls, indicators, and any custom content sit in the flow above or below the slides. The old .carousel-stacked class was removed—it’s now the default, so drop it from your markup.
  • Overlaid controls now require the .carousel-overlay modifier. To overlay the prev/next controls, play/pause button, and indicators on top of the slides (the classic v5 look), add .carousel-overlay to the .carousel element. Without it, those elements lay out in the flow.
  • Renamed the control-icon classes .carousel-control-prev-icon → .carousel-icon-prev and .carousel-control-next-icon → .carousel-icon-next. The icons are now painted with background-color: currentcolor, so they inherit the surrounding text color (white on the overlay controls, the button color inside .btn-*). Size them with --bs-carousel-control-icon-width.
  • Removed .carousel-caption and its --carousel-caption-* tokens. Compose slide content from your own markup inside .carousel-item instead, styling and positioning it with utilities or custom CSS.
  • Replaced the wrap option with ends. v5's wrap: true | false is now ends: "loop" | "wrap" | "stop" (default "loop"). Map wrap: true to ends: "wrap" (or the new default "loop" for the seamless conveyor effect) and wrap: false to ends: "stop". Set it via data-bs-ends or the ends option. Unknown values fall back to "loop".
  • Removed the .carousel-control-prev / .carousel-control-next button classes. The absolute, full-height hover targets are gone. Compose a control from a button (e.g. .btn-icon) plus data-bs-slide="prev" / data-bs-slide="next" and a .carousel-icon-prev / .carousel-icon-next glyph, placed in the flow or inside .carousel-overlay-controls.
  • Removed the .carousel-dark class. Use data-bs-theme="dark" on the .carousel (typically alongside .carousel-overlay) for reversed contrast.
  • Removed v5 carousel tokens that no longer have an equivalent: --carousel-caption-*, --carousel-control-color, --carousel-control-opacity / --carousel-control-hover-opacity, --carousel-control-icon-filter, and --carousel-transition. Indicator, control, and fade styling now derive from the redesigned --bs-carousel-* tokens listed under CSS variables.

Reboot

  • Relocated heading classes (like .h1) and some type classes (.mark, .small, and .initialism) to Reboot from _type.scss. This avoids a dependency in Sass modules and we like to avoid extending selectors in general.
  • Split the remaining _type.scss into _lists.scss and _blockquote.scss. Update any individual @use "bootstrap/scss/content/type" imports to content/lists and/or content/blockquote instead.
  • Headings, paragraphs, description lists, and <legend> now use CSS variables instead of Sass variables. Removed $headings-margin-bottom, $headings-font-family, $headings-font-style, $headings-font-weight, $headings-line-height, $headings-color, $paragraph-margin-bottom, $legend-margin-bottom, $legend-font-size, $legend-font-weight, and $dt-font-weight. Customize the equivalent --heading-*, --paragraph-margin-bottom, and --legend-* CSS variables at runtime instead—see Typography.
  • Removed $font-size-base and --font-size-base. The base body font size is now set directly via --body-font-size (default 1rem) in _root.scss. Any component tokens that previously fell back to var(--font-size-base) (like the accordion) now fall back to var(--body-font-size) instead. Update custom Sass or CSS that referenced either variable to use --body-font-size.
  • Heading and <dt> font-weight now fall back to shared weight tokens (font-weight: var(--heading-font-weight, var(--font-weight-medium)), var(--dt-font-weight, var(--font-weight-bold))) instead of a hardcoded value, so you can override either the component-specific token or the shared one.
  • Added --link-underline-offset to $root-tokens (mirroring $link-underline-offset) for runtime customization of the link underline offset.
  • Reboot and content spacing—address, lists, dd, blockquote, pre, figure, caption, kbd padding, and ol/ul padding-inline-start (now driven by a new --list-padding-x token)—now derive from the --spacer-* scale instead of hardcoded rem values. Visual output is unchanged.
  • Removed the ::-moz-focus-inner styles, as the pseudo selector is deprecated in Firefox.
  • Removed text-transform: none from button and select elements, as Firefox no longer incorrectly inherits text-transform.
  • Added accent-color: var(--primary-base) on :root, which applies the primary theme color to native form controls (checkboxes, radios, range inputs, progress bars) globally.
  • Reboot now sets color-scheme: light dark on every iframe. This keeps an embed transparent when you force a theme with data-bs-theme. Remove any v5 workaround like [data-bs-theme="dark"] { color-scheme: unset; }. v6 resolves its color tokens with light-dark(), which reads color-scheme. An unset there turns off dark mode for the whole subtree. For a third-party embed with no dark mode, add the new .color-scheme-light utility to that one iframe instead—see Reboot.

Forms