Answer
By default, Swiper compares breakpoint keys against the browser viewport/window width, not the Swiper container element width. Resizing only the container will not change slidesPerView or spaceBetween unless breakpointsBase: 'container' is supported by the installed release and explicitly set. Container-base support is version-dependent, so confirm the installed Swiper version before using it.
Established default versus version-dependent option
- Default:
breakpointsBase: 'window'; breakpoint keys match viewport width.
breakpointsBase: 'container' matches swiper.el width only in releases that document it; older releases may accept only 'window' or ignore unknown values.
- Loop mode makes
.swiper-slide counts unreliable because duplicated slides are inserted into the DOM.
Steps for this case
- Check the installed release:
node -p "require('./node_modules/swiper/package.json').version" or Swiper.version in the page console.
- If the installed release documents
breakpointsBase, set breakpointsBase: 'container'; otherwise keep the default 'window'.
- Assign unique
slidesPerView values per breakpoint so the active breakpoint is identifiable from params, not slide count.
- Log breakpoint resolution after initialization:
on: {
breakpoint(swiper, breakpointParams) {
console.log(
swiper.params.breakpointsBase,
breakpointParams,
'viewport', window.innerWidth,
'container', swiper.el.getBoundingClientRect().width
);
}
}
- Resize the viewport or container, then match the logged
breakpointParams to your breakpoint map. If nothing changes, make the container visible and run swiper.updateSize(), then confirm observeResize is enabled and Swiper is initialized.
Conditions that delay or suppress breakpoint updates
observeResize is off, or Swiper is destroyed or not initialized.
- The container is hidden or
display: none, often reporting zero width and suppressing ResizeObserver updates.
- ResizeObserver is unsupported or not delivering for the container.
breakpointsBase is changed after initialization without a later resize or size update.
Missing diagnostic
Provide the installed Swiper version (Swiper.version or package.json version). That is the one detail that changes whether breakpointsBase: 'container' is valid for your release. Treat this as a draft for review until that version is confirmed.