Migration Guide to Swiper 10

Swiper Element Layout

Swiper Element now comes with additional <div class="swiper"> main element internal layout.

In v9:

  <!-- shadow -->
  <div class="swiper-wrapper">
    <slot />

In v10:

  <!-- shadow -->
  <div class="swiper">
    <div class="swiper-wrapper">
      <slot />

So if you rely and do some tricks with shadow DOM internals, you need to consider new layout.

Swiper Element Styles

Swiper web component doesn't inject global styles to document anymore. In this case if you will use custom navigation, pagination, scrollbar elements they will be not styled.

Modules Imports

For better tree-shaking all modules must be imported now from /swiper/modules

In v9:

import Swiper, { Navigation, Pagination } from 'swiper';

In v10:

import Swiper from 'swiper';
import { Navigation, Pagination } from 'swiper/modules';

Package Structure

Main breaking change in v10 is the simplified package structure:

  • most of the files (except modules) are now in the package root
  • .esm.js scripts replaced with .mjs
  • .browser.esm.js scripts are now same .mjs

You need to consider it if you import files directly. Here is the new package structure: