Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • SwiperOptions

Index

Properties

Methods

Properties

Optional _emitClasses

_emitClasses: boolean

!INTERNAL When enabled will emit "_containerClasses" and "_slideClass" events

Optional a11y

Object with a11y parameters or boolean true to enable with default settings.

example
const swiper = new Swiper('.swiper', {
  a11y: {
    prevSlideMessage: 'Previous slide',
    nextSlideMessage: 'Next slide',
  },
});

Optional allowSlideNext

allowSlideNext: boolean

Set to false to disable swiping to next slide direction (to right or bottom)

default

true

Optional allowSlidePrev

allowSlidePrev: boolean

Set to false to disable swiping to previous slide direction (to left or top)

default

true

Optional allowTouchMove

allowTouchMove: boolean

If false, then the only way to switch the slide is use of external API functions like slidePrev or slideNext

default

true

Optional autoHeight

autoHeight: boolean

Set to true and slider wrapper will adapt its height to the height of the currently active slide

default

false

Optional autoplay

autoplay: boolean | AutoplayOptions

Object with autoplay parameters or boolean true to enable with default settings

example
const swiper = new Swiper('.swiper', {
 autoplay: {
   delay: 5000,
 },
});

Optional breakpoints

breakpoints: {}

Allows to set different parameter for different responsive breakpoints (screen sizes). Not all parameters can be changed in breakpoints, only those which do not require different layout and logic, like slidesPerView, slidesPerGroup, spaceBetween, grid.rows. Such parameters like loop and effect won't work

example
const swiper = new Swiper('.swiper', {
  // Default parameters
  slidesPerView: 1,
  spaceBetween: 10,
  // Responsive breakpoints
  breakpoints: {
    // when window width is >= 320px
    320: {
      slidesPerView: 2,
      spaceBetween: 20
    },
    // when window width is >= 480px
    480: {
      slidesPerView: 3,
      spaceBetween: 30
    },
    // when window width is >= 640px
    640: {
      slidesPerView: 4,
      spaceBetween: 40
    }
  }
})
example
const swiper = new Swiper('.swiper', {
  slidesPerView: 1,
  spaceBetween: 10,
  // using "ratio" endpoints
  breakpoints: {
    '@0.75': {
      slidesPerView: 2,
      spaceBetween: 20,
    },
    '@1.00': {
      slidesPerView: 3,
      spaceBetween: 40,
    },
    '@1.50': {
      slidesPerView: 4,
      spaceBetween: 50,
    },
  }
});

Type declaration

Optional breakpointsBase

breakpointsBase: string

Base for breakpoints (beta). Can be window or container. If set to window (by default) then breakpoint keys mean window width. If set to container then breakpoint keys treated as swiper container width

default

'window'

note

Currently in beta and not supported by Swiper Angular, React, Svelte and Vue components

Optional cardsEffect

cardsEffect: CardsEffectOptions

Object with Cards-effect parameters

example
const swiper = new Swiper('.swiper', {
  effect: 'cards',
  cardsEffect: {
    // ...
  },
});

Optional centerInsufficientSlides

centerInsufficientSlides: boolean

When enabled it center slides if the amount of slides less than slidesPerView. Not intended to be used loop mode and grid.rows

default

false

Optional centeredSlides

centeredSlides: boolean

If true, then active slide will be centered, not always on the left side.

default

false

Optional centeredSlidesBounds

centeredSlidesBounds: boolean

If true, then active slide will be centered without adding gaps at the beginning and end of slider. Required centeredSlides: true. Not intended to be used with loop or pagination

default

false

Optional containerModifierClass

containerModifierClass: string

The beginning of the modifier CSS class that can be added to swiper container depending on different parameters

default

'swiper-'

Optional controller

controller: ControllerOptions

Object with controller parameters or boolean true to enable with default settings

example
const swiper = new Swiper('.swiper', {
  controller: {
    inverse: true,
  },
});

Optional coverflowEffect

coverflowEffect: CoverflowEffectOptions

Object with Coverflow-effect parameters.

example
const swiper = new Swiper('.swiper', {
  effect: 'coverflow',
  coverflowEffect: {
    rotate: 30,
    slideShadows: false,
  },
});

Optional createElements

createElements: boolean

When enabled Swiper will automatically wrap slides with swiper-wrapper element, and will create required elements for navigation, pagination and scrollbar they are enabled (with their respective params object or with boolean true))

default

false

Optional creativeEffect

creativeEffect: CreativeEffectOptions

Object with Creative-effect parameters

example
const swiper = new Swiper('.swiper', {
  effect: 'creative',
  creativeEffect: {
    prev: {
      // will set `translateZ(-400px)` on previous slides
      translate: [0, 0, -400],
    },
    next: {
      // will set `translateX(100%)` on next slides
      translate: ['100%', 0, 0],
    },
  },
});

Optional cssMode

cssMode: boolean

When enabled it will use modern CSS Scroll Snap API. It doesn't support all of Swiper's features, but potentially should bring a much better performance in simple configurations.

This is what is not supported when it is enabled:

  • Cube and Cards effects
  • speed parameter may not have no effect
  • All transition start/end related events (use slideChange instead)
  • slidesPerGroup has limited support
  • simulateTouch doesn't have effect and "dragging" with mouse doesn't work
  • resistance doesn't have any effect
  • allowSlidePrev/Next
  • swipeHandler
  • freeMode and all relevant features
default

false

Optional cubeEffect

cubeEffect: CubeEffectOptions

Object with Cube-effect parameters

example
const swiper = new Swiper('.swiper', {
  effect: 'cube',
  cubeEffect: {
    slideShadows: false,
  },
});

Optional direction

direction: "horizontal" | "vertical"

Can be 'horizontal' or 'vertical' (for vertical slider).

default

'horizontal'

Optional edgeSwipeDetection

edgeSwipeDetection: string | boolean

Enable to release Swiper events for swipe-back work in app. If set to 'prevent' then it will prevent system swipe-back navigation instead

default

false

Optional edgeSwipeThreshold

edgeSwipeThreshold: number

Area (in px) from left edge of the screen to release touch events for swipe-back in app

default

20

Optional effect

effect: "slide" | "fade" | "cube" | "coverflow" | "flip" | "creative" | "cards"

Transition effect. Can be 'slide', 'fade', 'cube', 'coverflow', 'flip' or 'creative'

default

'slide'

Optional enabled

enabled: boolean

Whether Swiper initially enabled. When Swiper is disabled, it will hide all navigation elements and won't respond to any events and interactions

default

true

Optional fadeEffect

fadeEffect: FadeEffectOptions

Object with Fade-effect parameters

example
const swiper = new Swiper('.swiper', {
  effect: 'fade',
  fadeEffect: {
    crossFade: true
  },
});

Optional flipEffect

flipEffect: FlipEffectOptions

Object with Flip-effect parameters

example
const swiper = new Swiper('.swiper', {
  effect: 'flip',
  flipEffect: {
    slideShadows: false,
  },
});

Optional focusableElements

focusableElements: string

CSS selector for focusable elements. Swiping will be disabled on such elements if they are "focused"

default

'input, select, option, textarea, button, video, label'

Optional followFinger

followFinger: boolean

If disabled, then slider will be animated only when you release it, it will not move while you hold your finger on it

default

true

Optional freeMode

freeMode: boolean | FreeModeOptions

Enables free mode functionality. Object with free mode parameters or boolean true to enable with default settings.

example
const swiper = new Swiper('.swiper', {
  freeMode: true,
});

const swiper = new Swiper('.swiper', {
  freeMode: {
    enabled: true,
    sticky: true,
  },
});

Optional grabCursor

grabCursor: boolean

This option may a little improve desktop usability. If true, user will see the "grab" cursor when hover on Swiper

default

false

Optional grid

Object with grid parameters to enable "multirow" slider.

example
const swiper = new Swiper('.swiper', {
  grid: {
    rows: 2,
  },
});

Optional hashNavigation

hashNavigation: boolean | HashNavigationOptions

Enables hash url navigation to for slides. Object with hash navigation parameters or boolean true to enable with default settings

example
const swiper = new Swiper('.swiper', {
  hashNavigation: {
    replaceState: true,
  },
});

Optional height

height: null | number

Swiper height (in px). Parameter allows to force Swiper height. Useful only if you initialize Swiper when it is hidden and in SSR and Test environments for correct Swiper initialization

default

null

note

Setting this parameter will make Swiper not responsive

Optional history

history: boolean | HistoryOptions

Enables history push state where every slide will have its own url. In this parameter you have to specify main slides url like "slides" and specify every slide url using data-history attribute.

Object with history navigation parameters or boolean true to enable with default settings

example
const swiper = new Swiper('.swiper', {
  history: {
    replaceState: true,
  },
});
example
<!-- will produce "slides/slide1" url in browser history -->
<div class="swiper-slide" data-history="slide1"></div>

Optional init

init: boolean

Whether Swiper should be initialised automatically when you create an instance. If disabled, then you need to init it manually by calling swiper.init()

default

true

Optional initialSlide

initialSlide: number

Index number of initial slide.

default

0

Optional keyboard

keyboard: boolean | KeyboardOptions

Enables navigation through slides using keyboard. Object with keyboard parameters or boolean true to enable with default settings

example
const swiper = new Swiper('.swiper', {
  keyboard: {
    enabled: true,
    onlyInViewport: false,
  },
});

Optional lazy

lazy: boolean | LazyOptions

Enables images lazy loading. Object with lazy loading parameters or boolean true to enable with default settings

example
const swiper = new Swiper('.swiper', {
  lazy: {
    loadPrevNext: true,
  },
});

Optional longSwipes

longSwipes: boolean

Set to false if you want to disable long swipes

default

true

Optional longSwipesMs

longSwipesMs: number

Minimal duration (in ms) to trigger swipe to next/previous slide during long swipes

default

300

Optional longSwipesRatio

longSwipesRatio: number

Ratio to trigger swipe to next/previous slide during long swipes

default

0.5

Optional loop

loop: boolean

Set to true to enable continuous loop mode

Because of nature of how the loop mode works, it will add duplicated slides. Such duplicated slides will have additional classes:

  • swiper-slide-duplicate - represents duplicated slide
  • swiper-slide-duplicate-active - represents slide duplicated to the currently active slide
  • swiper-slide-duplicate-next - represents slide duplicated to the slide next to active
  • swiper-slide-duplicate-prev - represents slide duplicated to the slide previous to active
default

false

note

If you use it along with slidesPerView: 'auto' then you need to specify loopedSlides parameter with amount of slides to loop (duplicate). Should not be used together with rewind mode

Optional loopAdditionalSlides

loopAdditionalSlides: number

Addition number of slides that will be cloned after creating of loop

default

0

Optional loopFillGroupWithBlank

loopFillGroupWithBlank: boolean

Enable and loop mode will fill groups with insufficient number of slides with blank slides. Good to be used with slidesPerGroup parameter

default

false

Optional loopPreventsSlide

loopPreventsSlide: boolean

When enabled it prevents Swiper slide prev/next transitions when transitions is already in progress (has effect when loop enabled)

default

true

Optional loopedSlides

loopedSlides: null | number

If you use slidesPerView:'auto' with loop mode you should tell to Swiper how many slides it should loop (duplicate) using this parameter

default

null

Optional loopedSlidesLimit

loopedSlidesLimit: boolean

When enabled then amount of duplicated slides will not exceed amount of original slides. Useful to disable and increase loopedSlides when you have a lot of slides per view and not sufficient amount of original slides

default

true

Optional maxBackfaceHiddenSlides

maxBackfaceHiddenSlides: number

If total number of slides less than specified here value, then Swiper will enable backface-visibility: hidden on slide elements to reduce visual "flicker" in Safari.

note

It is not recommended to enable it on large amount of slides as it will reduce performance

default

10

Optional modules

modules: SwiperModule[]

Array with Swiper modules

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

const swiper = new Swiper('.swiper', {
   modules: [ Navigation, Pagination ],
 });

Optional mousewheel

mousewheel: boolean | MousewheelOptions

Enables navigation through slides using mouse wheel. Object with mousewheel parameters or boolean true to enable with default settings

example
const swiper = new Swiper('.swiper', {
  mousewheel: {
    invert: true,
  },
});

Optional navigation

navigation: boolean | NavigationOptions

Object with navigation parameters or boolean true to enable with default settings.

example
const swiper = new Swiper('.swiper', {
  navigation: {
    nextEl: '.swiper-button-next',
    prevEl: '.swiper-button-prev',
  },
});

Optional nested

nested: boolean

Set to true on Swiper for correct touch events interception. Use only on swipers that use same direction as the parent one

default

false

Optional noSwiping

noSwiping: boolean

Enable/disable swiping on elements matched to class specified in noSwipingClass

default

true

Optional noSwipingClass

noSwipingClass: string

Specify noSwiping's element css class

default

'swiper-no-swiping'

Optional noSwipingSelector

noSwipingSelector: string

Can be used instead of noSwipingClass to specify elements to disable swiping on. For example 'input' will disable swiping on all inputs

default

Optional normalizeSlideIndex

normalizeSlideIndex: boolean

Normalize slide index.

default

true

Optional observeParents

observeParents: boolean

Set to true if you also need to watch Mutations for Swiper parent elements

default

false

Optional observeSlideChildren

observeSlideChildren: boolean

Set to true if you also need to watch Mutations for Swiper slide children elements

default

false

Optional observer

observer: boolean

Set to true to enable Mutation Observer on Swiper and its elements. In this case Swiper will be updated (reinitialized) each time if you change its style (like hide/show) or modify its child elements (like adding/removing slides)

default

false

Optional on

on: { _beforeBreakpoint?: (swiper: default, breakpointParams: SwiperOptions) => void; _containerClasses?: (swiper: default, classNames: string) => void; _freeModeNoMomentumRelease?: (swiper: default) => void; _slideClass?: (swiper: default, slideEl: HTMLElement, classNames: string) => void; _slideClasses?: (swiper: default, slides: { classNames: string; index: number; slideEl: HTMLElement }[]) => void; _swiper?: (swiper: default) => void; activeIndexChange?: (swiper: default) => void; afterInit?: (swiper: default) => void; autoplay?: (swiper: default) => void; autoplayPause?: (swiper: default) => void; autoplayResume?: (swiper: default) => void; autoplayStart?: (swiper: default) => void; autoplayStop?: (swiper: default) => void; beforeDestroy?: (swiper: default) => void; beforeInit?: (swiper: default) => void; beforeLoopFix?: (swiper: default) => void; beforeResize?: (swiper: default) => void; beforeSlideChangeStart?: (swiper: default) => void; beforeTransitionStart?: (swiper: default, speed: number, internal: any) => void; breakpoint?: (swiper: default, breakpointParams: SwiperOptions) => void; changeDirection?: (swiper: default) => void; click?: (swiper: default, event: MouseEvent | TouchEvent | PointerEvent) => void; destroy?: (swiper: default) => void; doubleClick?: (swiper: default, event: MouseEvent | TouchEvent | PointerEvent) => void; doubleTap?: (swiper: default, event: MouseEvent | TouchEvent | PointerEvent) => void; fromEdge?: (swiper: default) => void; hashChange?: (swiper: default) => void; hashSet?: (swiper: default) => void; imagesReady?: (swiper: default) => void; init?: (swiper: default) => any; keyPress?: (swiper: default, keyCode: string) => void; lazyImageLoad?: (swiper: default, slideEl: HTMLElement, imageEl: HTMLElement) => void; lazyImageReady?: (swiper: default, slideEl: HTMLElement, imageEl: HTMLElement) => void; lock?: (swiper: default) => void; loopFix?: (swiper: default) => void; momentumBounce?: (swiper: default) => void; navigationHide?: (swiper: default) => void; navigationNext?: (swiper: default) => void; navigationPrev?: (swiper: default) => void; navigationShow?: (swiper: default) => void; observerUpdate?: (swiper: default) => void; orientationchange?: (swiper: default) => void; paginationHide?: (swiper: default) => void; paginationRender?: (swiper: default, paginationEl: HTMLElement) => void; paginationShow?: (swiper: default) => void; paginationUpdate?: (swiper: default, paginationEl: HTMLElement) => void; progress?: (swiper: default, progress: number) => void; reachBeginning?: (swiper: default) => void; reachEnd?: (swiper: default) => void; realIndexChange?: (swiper: default) => void; resize?: (swiper: default) => void; scroll?: (swiper: default, event: WheelEvent) => void; scrollbarDragEnd?: (swiper: default, event: MouseEvent | TouchEvent | PointerEvent) => void; scrollbarDragMove?: (swiper: default, event: MouseEvent | TouchEvent | PointerEvent) => void; scrollbarDragStart?: (swiper: default, event: MouseEvent | TouchEvent | PointerEvent) => void; setTransition?: (swiper: default, transition: number) => void; setTranslate?: (swiper: default, translate: number) => void; slideChange?: (swiper: default) => void; slideChangeTransitionEnd?: (swiper: default) => void; slideChangeTransitionStart?: (swiper: default) => void; slideNextTransitionEnd?: (swiper: default) => void; slideNextTransitionStart?: (swiper: default) => void; slidePrevTransitionEnd?: (swiper: default) => void; slidePrevTransitionStart?: (swiper: default) => void; slideResetTransitionEnd?: (swiper: default) => void; slideResetTransitionStart?: (swiper: default) => void; sliderFirstMove?: (swiper: default, event: TouchEvent) => void; sliderMove?: (swiper: default, event: MouseEvent | TouchEvent | PointerEvent) => void; slidesGridLengthChange?: (swiper: default) => void; slidesLengthChange?: (swiper: default) => void; snapGridLengthChange?: (swiper: default) => void; snapIndexChange?: (swiper: default) => void; tap?: (swiper: default, event: MouseEvent | TouchEvent | PointerEvent) => void; toEdge?: (swiper: default) => void; touchEnd?: (swiper: default, event: MouseEvent | TouchEvent | PointerEvent) => void; touchMove?: (swiper: default, event: MouseEvent | TouchEvent | PointerEvent) => void; touchMoveOpposite?: (swiper: default, event: MouseEvent | TouchEvent | PointerEvent) => void; touchStart?: (swiper: default, event: MouseEvent | TouchEvent | PointerEvent) => void; transitionEnd?: (swiper: default) => void; transitionStart?: (swiper: default) => void; unlock?: (swiper: default) => void; update?: (swiper: default) => void; zoomChange?: (swiper: default, scale: number, imageEl: HTMLElement, slideEl: HTMLElement) => void }

Register event handlers

Type declaration

  • Optional _beforeBreakpoint?: (swiper: default, breakpointParams: SwiperOptions) => void
  • Optional _containerClasses?: (swiper: default, classNames: string) => void
      • (swiper: default, classNames: string): void
      • !INTERNAL: Event will fired after setting CSS classes on swiper container element

        Parameters

        • swiper: default
        • classNames: string

        Returns void

  • Optional _freeModeNoMomentumRelease?: (swiper: default) => void
      • !INTERNAL: Event will be fired on free mode touch end (release) and there will no be momentum

        Parameters

        Returns void

  • Optional _slideClass?: (swiper: default, slideEl: HTMLElement, classNames: string) => void
      • (swiper: default, slideEl: HTMLElement, classNames: string): void
      • !INTERNAL: Event will fired after setting CSS classes on swiper slide element

        Parameters

        • swiper: default
        • slideEl: HTMLElement
        • classNames: string

        Returns void

  • Optional _slideClasses?: (swiper: default, slides: { classNames: string; index: number; slideEl: HTMLElement }[]) => void
      • (swiper: default, slides: { classNames: string; index: number; slideEl: HTMLElement }[]): void
      • !INTERNAL: Event will fired after setting CSS classes on all swiper slides

        Parameters

        • swiper: default
        • slides: { classNames: string; index: number; slideEl: HTMLElement }[]

        Returns void

  • Optional _swiper?: (swiper: default) => void
      • !INTERNAL: Event will fired as soon as swiper instance available (before init)

        Parameters

        Returns void

  • Optional activeIndexChange?: (swiper: default) => void
      • Event will fired on active index change

        Parameters

        Returns void

  • Optional afterInit?: (swiper: default) => void
      • Event will fired right after initialization

        Parameters

        Returns void

  • Optional autoplay?: (swiper: default) => void
      • Event will be fired when slide changed with autoplay

        Parameters

        Returns void

  • Optional autoplayPause?: (swiper: default) => void
      • Event will be fired on autoplay pause (on mouse/pointer enter), when pauseOnMouseEnter enabled

        Parameters

        Returns void

  • Optional autoplayResume?: (swiper: default) => void
      • Event will be fired on autoplay resume (on mouse/pointer leave), when pauseOnMouseEnter enabled

        Parameters

        Returns void

  • Optional autoplayStart?: (swiper: default) => void
      • Event will be fired in when autoplay started

        Parameters

        Returns void

  • Optional autoplayStop?: (swiper: default) => void
      • Event will be fired when autoplay stopped

        Parameters

        Returns void

  • Optional beforeDestroy?: (swiper: default) => void
      • Event will be fired right before Swiper destroyed

        Parameters

        Returns void

  • Optional beforeInit?: (swiper: default) => void
      • Event will fired right before initialization

        Parameters

        Returns void

  • Optional beforeLoopFix?: (swiper: default) => void
      • Event will be fired right before "loop fix"

        Parameters

        Returns void

  • Optional beforeResize?: (swiper: default) => void
      • Event will fired before resize handler

        Parameters

        Returns void

  • Optional beforeSlideChangeStart?: (swiper: default) => void
      • Event will fired before slide change transition start

        Parameters

        Returns void

  • Optional beforeTransitionStart?: (swiper: default, speed: number, internal: any) => void
      • (swiper: default, speed: number, internal: any): void
      • Event will fired before transition start

        Parameters

        • swiper: default
        • speed: number
        • internal: any

        Returns void

  • Optional breakpoint?: (swiper: default, breakpointParams: SwiperOptions) => void
  • Optional changeDirection?: (swiper: default) => void
      • Event will fired on direction change

        Parameters

        Returns void

  • Optional click?: (swiper: default, event: MouseEvent | TouchEvent | PointerEvent) => void
      • (swiper: default, event: MouseEvent | TouchEvent | PointerEvent): void
      • Event will be fired when user click/tap on Swiper. Receives touchend event as an arguments.

        Parameters

        • swiper: default
        • event: MouseEvent | TouchEvent | PointerEvent

        Returns void

  • Optional destroy?: (swiper: default) => void
      • Event will be fired on swiper destroy

        Parameters

        Returns void

  • Optional doubleClick?: (swiper: default, event: MouseEvent | TouchEvent | PointerEvent) => void
      • (swiper: default, event: MouseEvent | TouchEvent | PointerEvent): void
      • Event will be fired when user double click/tap on Swiper

        Parameters

        • swiper: default
        • event: MouseEvent | TouchEvent | PointerEvent

        Returns void

  • Optional doubleTap?: (swiper: default, event: MouseEvent | TouchEvent | PointerEvent) => void
      • (swiper: default, event: MouseEvent | TouchEvent | PointerEvent): void
      • Event will be fired when user double tap on Swiper's container. Receives touchend event as an arguments

        Parameters

        • swiper: default
        • event: MouseEvent | TouchEvent | PointerEvent

        Returns void

  • Optional fromEdge?: (swiper: default) => void
      • Event will be fired when Swiper goes from beginning or end position

        Parameters

        Returns void

  • Optional hashChange?: (swiper: default) => void
      • Event will be fired on window hash change

        Parameters

        Returns void

  • Optional hashSet?: (swiper: default) => void
      • Event will be fired when swiper updates the hash

        Parameters

        Returns void

  • Optional imagesReady?: (swiper: default) => void
      • Event will be fired right after all inner images are loaded. updateOnImagesReady should be also enabled

        Parameters

        Returns void

  • Optional init?: (swiper: default) => any
      • Fired right after Swiper initialization.

        Parameters

        Returns any

  • Optional keyPress?: (swiper: default, keyCode: string) => void
      • (swiper: default, keyCode: string): void
      • Event will be fired on key press

        Parameters

        Returns void

  • Optional lazyImageLoad?: (swiper: default, slideEl: HTMLElement, imageEl: HTMLElement) => void
      • (swiper: default, slideEl: HTMLElement, imageEl: HTMLElement): void
      • Event will be fired in the beginning of lazy loading of image

        Parameters

        • swiper: default
        • slideEl: HTMLElement
        • imageEl: HTMLElement

        Returns void

  • Optional lazyImageReady?: (swiper: default, slideEl: HTMLElement, imageEl: HTMLElement) => void
      • (swiper: default, slideEl: HTMLElement, imageEl: HTMLElement): void
      • Event will be fired when lazy loading image will be loaded

        Parameters

        • swiper: default
        • slideEl: HTMLElement
        • imageEl: HTMLElement

        Returns void

  • Optional lock?: (swiper: default) => void
      • Event will be fired when swiper is locked (when watchOverflow enabled)

        Parameters

        Returns void

  • Optional loopFix?: (swiper: default) => void
      • Event will be fired after "loop fix"

        Parameters

        Returns void

  • Optional momentumBounce?: (swiper: default) => void
      • Event will be fired on momentum bounce

        Parameters

        Returns void

  • Optional navigationHide?: (swiper: default) => void
      • Event will be fired on navigation hide

        Parameters

        Returns void

  • Optional navigationNext?: (swiper: default) => void
      • Event will be fired on navigation next button click

        Parameters

        Returns void

  • Optional navigationPrev?: (swiper: default) => void
      • Event will be fired on navigation prev button click

        Parameters

        Returns void

  • Optional navigationShow?: (swiper: default) => void
      • Event will be fired on navigation show

        Parameters

        Returns void

  • Optional observerUpdate?: (swiper: default) => void
      • Event will be fired if observer is enabled and it detects DOM mutations

        Parameters

        Returns void

  • Optional orientationchange?: (swiper: default) => void
      • Event will be fired on orientation change (e.g. landscape -> portrait)

        Parameters

        Returns void

  • Optional paginationHide?: (swiper: default) => void
      • Event will be fired on pagination hide

        Parameters

        Returns void

  • Optional paginationRender?: (swiper: default, paginationEl: HTMLElement) => void
      • (swiper: default, paginationEl: HTMLElement): void
      • Event will be fired after pagination rendered

        Parameters

        • swiper: default
        • paginationEl: HTMLElement

        Returns void

  • Optional paginationShow?: (swiper: default) => void
      • Event will be fired on pagination show

        Parameters

        Returns void

  • Optional paginationUpdate?: (swiper: default, paginationEl: HTMLElement) => void
      • (swiper: default, paginationEl: HTMLElement): void
      • Event will be fired when pagination updated

        Parameters

        • swiper: default
        • paginationEl: HTMLElement

        Returns void

  • Optional progress?: (swiper: default, progress: number) => void
      • (swiper: default, progress: number): void
      • Event will be fired when Swiper progress is changed, as an arguments it receives progress that is always from 0 to 1

        Parameters

        Returns void

  • Optional reachBeginning?: (swiper: default) => void
      • Event will be fired when Swiper reach its beginning (initial position)

        Parameters

        Returns void

  • Optional reachEnd?: (swiper: default) => void
      • Event will be fired when Swiper reach last slide

        Parameters

        Returns void

  • Optional realIndexChange?: (swiper: default) => void
      • Event will fired on real index change

        Parameters

        Returns void

  • Optional resize?: (swiper: default) => void
      • Event will be fired on window resize right before swiper's onresize manipulation

        Parameters

        Returns void

  • Optional scroll?: (swiper: default, event: WheelEvent) => void
      • (swiper: default, event: WheelEvent): void
      • Event will be fired on mousewheel scroll

        Parameters

        • swiper: default
        • event: WheelEvent

        Returns void

  • Optional scrollbarDragEnd?: (swiper: default, event: MouseEvent | TouchEvent | PointerEvent) => void
      • (swiper: default, event: MouseEvent | TouchEvent | PointerEvent): void
      • Event will be fired on draggable scrollbar drag end

        Parameters

        • swiper: default
        • event: MouseEvent | TouchEvent | PointerEvent

        Returns void

  • Optional scrollbarDragMove?: (swiper: default, event: MouseEvent | TouchEvent | PointerEvent) => void
      • (swiper: default, event: MouseEvent | TouchEvent | PointerEvent): void
      • Event will be fired on draggable scrollbar drag move

        Parameters

        • swiper: default
        • event: MouseEvent | TouchEvent | PointerEvent

        Returns void

  • Optional scrollbarDragStart?: (swiper: default, event: MouseEvent | TouchEvent | PointerEvent) => void
      • (swiper: default, event: MouseEvent | TouchEvent | PointerEvent): void
      • Event will be fired on draggable scrollbar drag start

        Parameters

        • swiper: default
        • event: MouseEvent | TouchEvent | PointerEvent

        Returns void

  • Optional setTransition?: (swiper: default, transition: number) => void
      • (swiper: default, transition: number): void
      • Event will be fired everytime when swiper starts animation. Receives current transition duration (in ms) as an arguments

        Parameters

        • swiper: default
        • transition: number

        Returns void

  • Optional setTranslate?: (swiper: default, translate: number) => void
      • (swiper: default, translate: number): void
      • Event will be fired when swiper's wrapper change its position. Receives current translate value as an arguments

        Parameters

        • swiper: default
        • translate: number

        Returns void

  • Optional slideChange?: (swiper: default) => void
      • Event will be fired when currently active slide is changed

        Parameters

        Returns void

  • Optional slideChangeTransitionEnd?: (swiper: default) => void
      • Event will be fired after animation to other slide (next or previous).

        Parameters

        Returns void

  • Optional slideChangeTransitionStart?: (swiper: default) => void
      • Event will be fired in the beginning of animation to other slide (next or previous).

        Parameters

        Returns void

  • Optional slideNextTransitionEnd?: (swiper: default) => void
      • Same as "slideChangeTransitionEnd" but for "forward" direction only

        Parameters

        Returns void

  • Optional slideNextTransitionStart?: (swiper: default) => void
      • Same as "slideChangeTransitionStart" but for "forward" direction only

        Parameters

        Returns void

  • Optional slidePrevTransitionEnd?: (swiper: default) => void
      • Same as "slideChangeTransitionEnd" but for "backward" direction only

        Parameters

        Returns void

  • Optional slidePrevTransitionStart?: (swiper: default) => void
      • Same as "slideChangeTransitionStart" but for "backward" direction only

        Parameters

        Returns void

  • Optional slideResetTransitionEnd?: (swiper: default) => void
      • Event will be fired in the end of animation of resetting slide to current one

        Parameters

        Returns void

  • Optional slideResetTransitionStart?: (swiper: default) => void
      • Event will be fired in the beginning of animation of resetting slide to current one

        Parameters

        Returns void

  • Optional sliderFirstMove?: (swiper: default, event: TouchEvent) => void
      • (swiper: default, event: TouchEvent): void
      • Event will be fired with first touch/drag move

        Parameters

        • swiper: default
        • event: TouchEvent

        Returns void

  • Optional sliderMove?: (swiper: default, event: MouseEvent | TouchEvent | PointerEvent) => void
      • (swiper: default, event: MouseEvent | TouchEvent | PointerEvent): void
      • Event will be fired when user touch and move finger over Swiper and move it. Receives touchmove event as an arguments.

        Parameters

        • swiper: default
        • event: MouseEvent | TouchEvent | PointerEvent

        Returns void

  • Optional slidesGridLengthChange?: (swiper: default) => void
      • Event will be fired when slides grid has changed

        Parameters

        Returns void

  • Optional slidesLengthChange?: (swiper: default) => void
      • Event will be fired when number of slides has changed

        Parameters

        Returns void

  • Optional snapGridLengthChange?: (swiper: default) => void
      • Event will be fired when snap grid has changed

        Parameters

        Returns void

  • Optional snapIndexChange?: (swiper: default) => void
      • Event will fired on snap index change

        Parameters

        Returns void

  • Optional tap?: (swiper: default, event: MouseEvent | TouchEvent | PointerEvent) => void
      • (swiper: default, event: MouseEvent | TouchEvent | PointerEvent): void
      • Event will be fired when user click/tap on Swiper. Receives touchend event as an arguments.

        Parameters

        • swiper: default
        • event: MouseEvent | TouchEvent | PointerEvent

        Returns void

  • Optional toEdge?: (swiper: default) => void
      • Event will be fired when Swiper goes to beginning or end position

        Parameters

        Returns void

  • Optional touchEnd?: (swiper: default, event: MouseEvent | TouchEvent | PointerEvent) => void
      • (swiper: default, event: MouseEvent | TouchEvent | PointerEvent): void
      • Event will be fired when user release Swiper. Receives touchend event as an arguments.

        Parameters

        • swiper: default
        • event: MouseEvent | TouchEvent | PointerEvent

        Returns void

  • Optional touchMove?: (swiper: default, event: MouseEvent | TouchEvent | PointerEvent) => void
      • (swiper: default, event: MouseEvent | TouchEvent | PointerEvent): void
      • Event will be fired when user touch and move finger over Swiper. Receives touchmove event as an arguments.

        Parameters

        • swiper: default
        • event: MouseEvent | TouchEvent | PointerEvent

        Returns void

  • Optional touchMoveOpposite?: (swiper: default, event: MouseEvent | TouchEvent | PointerEvent) => void
      • (swiper: default, event: MouseEvent | TouchEvent | PointerEvent): void
      • Event will be fired when user touch and move finger over Swiper in direction opposite to direction parameter. Receives touchmove event as an arguments.

        Parameters

        • swiper: default
        • event: MouseEvent | TouchEvent | PointerEvent

        Returns void

  • Optional touchStart?: (swiper: default, event: MouseEvent | TouchEvent | PointerEvent) => void
      • (swiper: default, event: MouseEvent | TouchEvent | PointerEvent): void
      • Event will be fired when user touch Swiper. Receives touchstart event as an arguments.

        Parameters

        • swiper: default
        • event: MouseEvent | TouchEvent | PointerEvent

        Returns void

  • Optional transitionEnd?: (swiper: default) => void
      • Event will be fired after transition.

        Parameters

        Returns void

  • Optional transitionStart?: (swiper: default) => void
      • Event will be fired in the beginning of transition.

        Parameters

        Returns void

  • Optional unlock?: (swiper: default) => void
      • Event will be fired when swiper is unlocked (when watchOverflow enabled)

        Parameters

        Returns void

  • Optional update?: (swiper: default) => void
      • Event will be fired after swiper.update() call

        Parameters

        Returns void

  • Optional zoomChange?: (swiper: default, scale: number, imageEl: HTMLElement, slideEl: HTMLElement) => void
      • (swiper: default, scale: number, imageEl: HTMLElement, slideEl: HTMLElement): void
      • Event will be fired on zoom change

        Parameters

        • swiper: default
        • scale: number
        • imageEl: HTMLElement
        • slideEl: HTMLElement

        Returns void

Optional pagination

pagination: boolean | PaginationOptions

Object with pagination parameters or boolean true to enable with default settings.

example
const swiper = new Swiper('.swiper', {
  pagination: {
    el: '.swiper-pagination',
    type: 'bullets',
  },
});

Optional parallax

parallax: boolean | ParallaxOptions

Object with parallax parameters or boolean true to enable with default settings.

example
const swiper = new Swiper('.swiper', {
  parallax: true,
});

Optional passiveListeners

passiveListeners: boolean

Passive event listeners will be used by default where possible to improve scrolling performance on mobile devices. But if you need to use e.preventDefault and you have conflict with it, then you should disable this parameter

default

true

Optional preloadImages

preloadImages: boolean

When enabled Swiper will force to load all images

default

true

Optional preventClicks

preventClicks: boolean

Set to true to prevent accidental unwanted clicks on links during swiping

default

true

Optional preventClicksPropagation

preventClicksPropagation: boolean

Set to true to stop clicks event propagation on links during swiping

default

true

Optional preventInteractionOnTransition

preventInteractionOnTransition: boolean

When enabled it won't allow to change slides by swiping or navigation/pagination buttons during transition

default

false

Optional resistance

resistance: boolean

Set to false if you want to disable resistant bounds

default

true

Optional resistanceRatio

resistanceRatio: number

This option allows you to control resistance ratio

default

0.85

Optional resizeObserver

resizeObserver: boolean

When enabled it will use ResizeObserver (if supported by browser) on swiper container to detect container resize (instead of watching for window resize)

default

true

Optional rewind

rewind: boolean

Set to true to enable "rewind" mode. When enabled, clicking "next" navigation button (or calling .slideNext()) when on last slide will slide back to the first slide. Clicking "prev" navigation button (or calling .slidePrev()) when on first slide will slide forward to the last slide.

default

false

note

Should not be used together with loop mode

Optional roundLengths

roundLengths: boolean

Set to true to round values of slides width and height to prevent blurry texts on usual resolution screens (if you have such)

default

false

Optional runCallbacksOnInit

runCallbacksOnInit: boolean

Fire Transition/SlideChange/Start/End events on swiper initialization. Such events will be fired on initialization in case of your initialSlide is not 0, or you use loop mode

default

true

Optional scrollbar

scrollbar: boolean | ScrollbarOptions

Object with scrollbar parameters or boolean true to enable with default settings.

example
const swiper = new Swiper('.swiper', {
  scrollbar: {
    el: '.swiper-scrollbar',
    draggable: true,
  },
});

Optional setWrapperSize

setWrapperSize: boolean

Enabled this option and plugin will set width/height on swiper wrapper equal to total size of all slides. Mostly should be used as compatibility fallback option for browser that don't support flexbox layout well

default

false

Optional shortSwipes

shortSwipes: boolean

Set to false if you want to disable short swipes

default

true

Optional simulateTouch

simulateTouch: boolean

If true, Swiper will accept mouse events like touch events (click and drag to change slides)

default

true

Optional slideActiveClass

slideActiveClass: string

CSS class name of currently active slide

default

'swiper-slide-active'

note

By changing classes you will also need to change Swiper's CSS to reflect changed classes

note

Not supported in Swiper Angular/React/Svelte/Vue components

Optional slideBlankClass

slideBlankClass: string

CSS class name of blank slide append to fill groups in loop mode when loopFillGroupWithBlank is also enabled

default

'swiper-slide-invisible-blank'

note

By changing classes you will also need to change Swiper's CSS to reflect changed classes

note

Not supported in Swiper Angular/React/Svelte/Vue

Optional slideClass

slideClass: string

CSS class name of slide

default

'swiper-slide'

note

By changing classes you will also need to change Swiper's CSS to reflect changed classes

note

Not supported in Swiper Angular/React/Svelte/Vue components

Optional slideDuplicateActiveClass

slideDuplicateActiveClass: string

CSS class name of duplicated slide which represents the currently active slide

default

'swiper-slide-duplicate-active'

note

By changing classes you will also need to change Swiper's CSS to reflect changed classes

note

Not supported in Swiper Angular/React/Svelte/Vue components

Optional slideDuplicateClass

slideDuplicateClass: string

CSS class name of slide duplicated by loop mode

default

'swiper-slide-duplicate'

note

By changing classes you will also need to change Swiper's CSS to reflect changed classes

note

Not supported in Swiper Angular/React/Svelte/Vue

Optional slideDuplicateNextClass

slideDuplicateNextClass: string

CSS class name of duplicated slide which represents the slide next to active slide

default

'swiper-slide-duplicate-next'

note

By changing classes you will also need to change Swiper's CSS to reflect changed classes

note

Not supported in Swiper Angular/React/Svelte/Vue

Optional slideDuplicatePrevClass

slideDuplicatePrevClass: string

CSS class name of duplicated slide which represents the slide previous to active slide

default

'swiper-slide-duplicate-prev'

note

By changing classes you will also need to change Swiper's CSS to reflect changed classes

note

Not supported in Swiper Angular/React/Svelte/Vue

Optional slideNextClass

slideNextClass: string

CSS class name of slide which is right after currently active slide

default

'swiper-slide-next'

note

By changing classes you will also need to change Swiper's CSS to reflect changed classes

note

Not supported in Swiper Angular/React/Svelte/Vue

Optional slidePrevClass

slidePrevClass: string

CSS class name of slide which is right before currently active slide

default

'swiper-slide-prev'

note

By changing classes you will also need to change Swiper's CSS to reflect changed classes

note

Not supported in Swiper Angular/React/Svelte/Vue

Optional slideToClickedSlide

slideToClickedSlide: boolean

Set to true and click on any slide will produce transition to this slide

default

false

Optional slideVisibleClass

slideVisibleClass: string

CSS class name of currently visible slide

default

'swiper-slide-visible'

note

By changing classes you will also need to change Swiper's CSS to reflect changed classes

note

Not supported in Swiper Angular/React/Svelte/Vue

Optional slidesOffsetAfter

slidesOffsetAfter: number

Add (in px) additional slide offset in the end of the container (after all slides)

default

0

Optional slidesOffsetBefore

slidesOffsetBefore: number

Add (in px) additional slide offset in the beginning of the container (before all slides)

default

0

Optional slidesPerGroup

slidesPerGroup: number

Set numbers of slides to define and enable group sliding. Useful to use with slidesPerView > 1

default

1

Optional slidesPerGroupAuto

slidesPerGroupAuto: boolean

This param intended to be used only with slidesPerView: 'auto' and slidesPerGroup: 1. When enabled, it will skip all slides in view on .slideNext() & .slidePrev() methods calls, on Navigation "buttons" clicks and in autoplay.

default

false

Optional slidesPerGroupSkip

slidesPerGroupSkip: number

The parameter works in the following way: If slidesPerGroupSkip equals 0 (default), no slides are excluded from grouping, and the resulting behaviour is the same as without this change.

If slidesPerGroupSkip is equal or greater than 1 the first X slides are treated as single groups, whereas all following slides are grouped by the slidesPerGroup value.

default

0

Optional slidesPerView

slidesPerView: number | "auto"

Number of slides per view (slides visible at the same time on slider's container).

note

If you use it with "auto" value and along with loop: true then you need to specify loopedSlides parameter with amount of slides to loop (duplicate)

note

slidesPerView: 'auto' is currently not compatible with multirow mode, when grid.rows > 1

default

1

Optional spaceBetween

spaceBetween: number

Distance between slides in px.

default

0

note

If you use "margin" css property to the elements which go into Swiper in which you pass "spaceBetween" into, navigation might not work properly.

Optional speed

speed: number

Duration of transition between slides (in ms)

default

300

Optional swipeHandler

swipeHandler: null | CSSSelector | HTMLElement

String with CSS selector or HTML element of the container with pagination that will work as only available handler for swiping

default

null

Optional threshold

threshold: number

Threshold value in px. If "touch distance" will be lower than this value then swiper will not move

default

0

Optional thumbs

Object with thumbs component parameters

example
const swiper = new Swiper('.swiper', {
  ...
  thumbs: {
    swiper: thumbsSwiper
  }
});

Optional touchAngle

touchAngle: number

Allowable angle (in degrees) to trigger touch move

default

45

Optional touchEventsTarget

touchEventsTarget: "container" | "wrapper"

Target element to listen touch events on. Can be 'container' (to listen for touch events on swiper) or 'wrapper' (to listen for touch events on swiper-wrapper)

default

'wrapper'

Optional touchMoveStopPropagation

touchMoveStopPropagation: boolean

If enabled, then propagation of "touchmove" will be stopped

default

false

Optional touchRatio

touchRatio: number

Touch ratio

default

1

Optional touchReleaseOnEdges

touchReleaseOnEdges: boolean

Enable to release touch events on slider edge position (beginning, end) to allow for further page scrolling

default

false

Optional touchStartForcePreventDefault

touchStartForcePreventDefault: boolean

Force to always prevent default for touchstart (pointerdown) event

default

false

Optional touchStartPreventDefault

touchStartPreventDefault: boolean

If disabled, touchstart (pointerdown) event won't be prevented

default

true

Optional uniqueNavElements

uniqueNavElements: boolean

If enabled (by default) and navigation elements' parameters passed as a string (like ".pagination") then Swiper will look for such elements through child elements first. Applies for pagination, prev/next buttons and scrollbar elements

default

true

Optional updateOnImagesReady

updateOnImagesReady: boolean

When enabled Swiper will be reinitialized after all inner images ( tags) are loaded. Required preloadImages: true

default

true

Optional updateOnWindowResize

updateOnWindowResize: boolean

Swiper will recalculate slides position on window resize (orientationchange)

default

true

Optional url

url: null | string

Required for active slide detection when rendered on server-side and enabled history

default

null

Optional userAgent

userAgent: null | string

userAgent string. Required for browser/device detection when rendered on server-side

default

null

Optional virtual

virtual: boolean | VirtualOptions

Enables virtual slides functionality. Object with virtual slides parameters or boolean true to enable with default settings.

example
const swiper = new Swiper('.swiper', {
  virtual: {
    slides: ['Slide 1', 'Slide 2', 'Slide 3', 'Slide 4', 'Slide 5'],
  },
});

Optional virtualTranslate

virtualTranslate: boolean

Enabled this option and swiper will be operated as usual except it will not move, real translate values on wrapper will not be set. Useful when you may need to create custom slide transition

default

false

Optional watchOverflow

watchOverflow: boolean

When enabled Swiper will be disabled and hide navigation buttons on case there are not enough slides for sliding.

default

true

Optional watchSlidesProgress

watchSlidesProgress: boolean

Enable this feature to calculate each slides progress and visibility (slides in viewport will have additional visible class)

default

false

Optional width

width: null | number

Swiper width (in px). Parameter allows to force Swiper width. Useful only if you initialize Swiper when it is hidden and in SSR and Test environments for correct Swiper initialization

default

null

note

Setting this parameter will make Swiper not responsive

Optional wrapperClass

wrapperClass: string

CSS class name of slides' wrapper

default

'swiper-wrapper'

note

By changing classes you will also need to change Swiper's CSS to reflect changed classes

note

Not supported in Swiper Angular/React/Svelte/Vue

Optional zoom

zoom: boolean | ZoomOptions

Enables zooming functionality. Object with zoom parameters or boolean true to enable with default settings

example
const swiper = new Swiper('.swiper', {
  zoom: {
    maxRatio: 5,
  },
});

Methods

Optional onAny

  • onAny(handler: (eventName: string, ...args: any[]) => void): void
  • Add event listener that will be fired on all events

    example
    const swiper = new Swiper('.swiper', {
       onAny(eventName, ...args) {
         console.log('Event: ', eventName);
         console.log('Event data: ', args);
       }
     });
    

    Parameters

    • handler: (eventName: string, ...args: any[]) => void
        • (eventName: string, ...args: any[]): void
        • Parameters

          • eventName: string
          • Rest ...args: any[]

          Returns void

    Returns void

Generated using TypeDoc