SwiperJS is a free and open-source JavaScript API that allows the creation of modern sliders supported by hardware-accelerated transitions. The sliders are intended for desktop websites, mobile (web) apps, and native or hybrid mobile environments.
The Swiper API documentation pages are based on version v11.2.1 (January 7, 2025) for the current version of J1 template (2025.x). The documentation can generally be used for all web browser-based projects that use SwiperJS for creating sliders.
The idea of providing this documentation is not to copy the original pages as duplicates. All pages are restructured and enhanced with code examples or improved by additional description texts for better readability and usability. |
Introduction
The terms carousel and slider are often used synonymously, but in today’s web design, they refer to different concepts and functionalities. Carousels like sliders are components for cycling through image or text elements in an endless loop.
A carousel is a simple slide show that cycles through a series of images or text content. Both can support controls and indicators for previous/next steps. Still, carousels do not support adjustable transitions from slide to slide or automatic normalization of the dimensions of the elements displayed.
A slider is an extended form of the carousel. Sliders support a rotating, moving display that not only changes in one direction (like a carousel) but also in both directions so that the user can jump back and forth in the display of the elements.
A slider can display several elements at the same time or enable smooth navigation between different elements within the display. Sliders are more interactive and contain more than just images or text like video, audio, or other dynamic content.
Silders versus Swipers
Swipers are fully configurable sliders based on a rich Application Interface (API). The SwiperJS programming interface allows developers to create individual user interfaces (UI) for pagination, navigation, and more. Find many complex examples on the pages of the UI Initiative project.
The rich API makes SwiperJS an excellent choice for web developers, not least for a template systems like J1 Template. In the current version of the J1 Template (version 2025.x), Swipers are the default sliders and replaces the previously used carousels and sliders Owl Carousel, Slickslider, and Masterslider by their implementations based on the SwiperJS API.
What SwiperJS Apps are
SwiperJS Apps are preconfigured sliders (swipers) that use the SwiperJS API as a base and combine it with other libraries like AmplitudeJS, VideoJS, and Photoswipe to create powerful and modern slide shows to be embedded in webpages of a J1 Template based site.
SwiperJS Apps create sliders that display text, images, videos, or audio files. They can be used to create simple sliders or more complex slide shows with different type of content. SwiperJS Apps are defined by pure configuration and do not require any programming. |
Find selected examples of available Swipers on page SwiperJS Tester.
HTML Layout
A HTML Layout is required to define the slides (images) to be used by a Swiper slider. Find the HTML Layout also with the Swiper Documentation.
Base HTML Layout v1
Ut culpa sit in est harum voluptates recusandae deleniti minima sit quis pariatur ullam enim. Quo placeat totam sit. Totam blanditiis sint rerum fugiat nemo corrupti eius.
<!-- Slider main container (required) -->
<div id="gallery_id" class="swiper swiper-container">
<!-- Slider wrapper element (required) -->
<div class="swiper-wrapper">
<!-- Slides (required) -->
<div class="swiper-slide">
<img src="<path_to>/image-1.jpg">
</div>
<!-- more slides -->
<div class="swiper-slide">
<img src="<path_to>/image-x.jpg">
</div>
</div> <!-- END wrapper element -->
<!-- Sniper Pagination (optional) -->
<div class="swiper-pagination"></div>
<!-- Sniper Navigation (optional) -->
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
<!-- Sniper Scrollbar (optional)-->
<div class="swiper-scrollbar"></div>
</div> <!-- END Main container -->
Base HTML Layout v2
Labore ratione et eos vel non repellendus. Eligendi ut placeat repellendus corporis autem. Fugiat vero illo quo dolorem quidem aliquam adipisci voluptas aliquam earum ipsum doloremque nihil.
<!-- Slider main container (required) -->
<div id="gallery_id" class="swiper swiper-container">
<!-- Slider wrapper element (required) -->
<ul class="swiper-wrapper">
<!-- Slides (required) -->
<li class="swiper-slide">
<img src="<path_to>/image-1.jpg">
</li>
<!-- more slides -->
<li class="swiper-slide">
<img src="<path_to>/image-x.jpg">
</li>
</ul> <!-- END swiper-wrapper (slides) -->
<!-- Sniper Pagination (optional) -->
<div class="swiper-pagination"></div>
<!-- Sniper Navigation (optional) -->
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
<!-- Sniper Scrollbar (optional)-->
<div class="swiper-scrollbar"></div>
</div> <!-- END Main container -->
Extended HTML Layout
Molestiae quam vel nemo asperiores. Ipsa dolorum et labore doloribus ducimus aliquid est non accusamus nemo sed delectus quidem. Dolor voluptas aspernatur aut voluptatem dolore veniam ipsa nostrum eius ea ut.
<!-- Slider main container (required) -->
<div id="gallery_id" class="swiper swiper-container">
<!-- Slider wrapper element (required) -->
<ul class="swiper-wrapper">
<!-- Slides (required) -->
<li class="swiper-slide">
<a href="<path_to>/image-1.jpg"
data-pswp-width="<max_width>"
data-pswp-height="<max_height>">
<img src="<path_to>/image-1.jpg" alt="Image 1">
<span class="pswp-caption-content">Caption: Image 1</span>
</a>
</li>
<!-- more slides -->
<li class="swiper-slide">
<a href="<path_to>/image-x.jpg"
data-pswp-width="<max_width>"
data-pswp-height="<max_height>">
<img src="<path_to>/image-x.jpg" alt="Image X">
<span class="pswp-caption-content">Caption: Image X</span>
</a>
</li>
</ul> <!-- END swiper-wrapper (slides) -->
<!-- Sniper Pagination (optional) -->
<div class="swiper-pagination"></div>
<!-- Sniper Navigation (optional) -->
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
<!-- Sniper Scrollbar (optional)-->
<div class="swiper-scrollbar"></div>
</div> <!-- END Main container -->
Initialization
When the Swiper HTML layout is in place, a initialization is reqired to create a slider (instance). Find initialization also with the Swiper Documentation.
// initialize swiper instance with options
const swiper = new Swiper(
swiperContainer,
parameters
);
- swiperContainer
-
HTML Element or string (with CSS Selector) of swiper a container HTML element (required).
- parameters
-
Object with Swiper parameters (ptional).
// Initialize a slider and create a instance variable (for later access)
const swiper = new Swiper(
'.swiper',
{
speed: 400,
spaceBetween: 100
}
);
The method |
After swiper initialization, it is possible to access to the swiper instance.
// Create an instance variable
const swiper = document.querySelector('.swiper').swiper;
// Access the sliders instance (e.g. by a method) like so
swiper.slideNext();
Common Options
Find a full list of all swiper options, aka known as properties, with the Swiper Documentation and with the Parameters sections below.
The properties for a Swiper slider are extensive, covering various aspects of its behavior and appearance. Here’s a summary of the key default values.
Base Settings
Name | Default | Description |
---|---|---|
horizontal | Slides move horizontally by default | |
slide | Base sliding transition by default | |
0 | No space (gutters) in between the slides by default | |
1 | Only one slide visible at a time by default | |
0 | First slide active initially by default | |
`false | Active slide not centered by default | |
| Continuous looping disabled by default |
User Interaction
Name | Default | Description |
---|---|---|
| Swiping enabled by default | |
| Cursor doesn’t change on hover by default | |
| Keyboard navigation disabled by default | |
false` | Mousewheel navigation disabled by default | |
no default | Pagination Elements (like bullets) disabled by default | |
no default | Navigation buttons disabled by default | |
no default | Scrollbar disabled by default |
Appearance
Name | Default | Description |
---|---|---|
| Slider height doesn’t adjust to slide content by default | |
300 | Transition animation duration between slides in ms. |
Page control
Name | Default | Description |
---|---|---|
no default | No responsive breakpoints defined by default |
Options A - K
List of available Swiper parameters (properties) alphabetically ordered from A to K. Find parameter settings also with the Swiper Documentation.
a11y (Accessibility)
Enable and configure the Accessibility (a11y) module with default settings. By using the module, SwiperJS slider accessibility is significantly enhanced for users having disabilities.
Find all available configurable settings with Accessibility (a11y) in section Modules. |
Name | Type | Default | Description | Example |
---|---|---|---|
| any | no default | Object with a11y parameters or boolean
|
allowslideNext()
Enable or disable swiping to next slide.
Name | Type | Default | Description | Example |
---|---|---|---|
| boolean | true | Set to |
allowslidePrev()
Enable or disable swiping to previous slide.
Name | Type | Default | Description | Example |
---|---|---|---|
| boolean | true | Set to |
allowTouchMove
Control to switch slides by using API methods like slidePrev() or slideNext().
Name | Type | Default | Description | Example |
---|---|---|---|
| boolean | true | If |
autoHeight
Set the slider wrapper to adapt its height from the height of the currently active slide.
Name | Type | Default | Description | Example |
---|---|---|---|
| boolean | false | Set to |
autoplay
Enable and configure the Autoplay module for auto playing behaviour of a SwiperJS slider.
Find all available configurable settings with Autoplay in section hModules>>. |
Name | Type | Default | Description | Example |
---|---|---|---|
| any | no default | Object with autoplay parameters or boolean
|
breakpoints
Allows to set parameters for responsive breakpoints.
Name | Type | Default | Description | Example | ||
---|---|---|---|---|---|
| object | no default | 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
|
breakpointsBase
Specify the base for breakpoints.
Name | Type | Default | Description | Example |
---|---|---|---|
| any | window | Base for breakpoints. Can be window or container. If set to window (by default) then breakpoint keys mean window width. If set to |
cardsEffect
Specify Cards-effect parameters.
Name | Type | Default | Description | Example |
---|---|---|---|
| any | no default | Object with Cards-effect parameters.
|
centerInsufficientSlides
Enabe or disable to center slides.
Name | Type | Default | Description | Example | ||
---|---|---|---|---|---|
| boolean | false | When enabled it center slides if the amount of slides less than
|
centeredSlides
Control to center active slides.
Name | Type | Default | Description | Example |
---|---|---|---|
| boolean | false | If |
centeredSlidesBounds
Control to center active slides without adding gaps.
Not intended to be used with |
Name | Type | Default | Description | Example | ||
---|---|---|---|---|---|
| boolean | false | If
|
containerModifierClass
The beginning of the modifier CSS class to center slides.
Name | Type | Default | Description | Example |
---|---|---|---|
| string | swiper- | The beginning of the modifier CSS class that can be added to swiper container depending on different parameters. |
controller
The Controller module allows to synchronize the movement of multiple slider instances. Find below how to set Swiper controller parameters.
Find all available configurable settings with Controller in section Modules. |
Name | Type | Default | Description | Example |
---|---|---|---|
| any | no default | Object with controller parameters or boolean
|
coverflowEffect
The Coverflow Effect module for SwiperJS creates a three-dimensional, fan-like effect for the slides in a Swiper container. This effect is inspired by the Coverflow view that you can see, for example, when selecting albums in iTunes.
Find below how to set Coverflow Effect parameters.
Name | Type | Default | Description | Example |
---|---|---|---|
| any | no default | Object with Coverflow-effect parameters.
|
createElements
Control how to wrap slides by an swiper-wrapper element.
Name | Type | Default | Description | Example |
---|---|---|---|
| boolean | false | 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 |
creativeEffect
The creative effect module in SwiperJS generates creative and engaging visual effects for the slides in a Swiper. The module allows for various custom transformations to animate the slides dynamically as they transition between each slide.
Name | Type | Default | Description | Example |
---|---|---|---|
| any | no default | Object with Creative-effect parameters
|
cssMode
Enable or disable CSS Scroll Snap API.
Name | Type | Default | Description | Example |
---|---|---|---|
| boolean | false | When enabled, Swiper 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:
In case if you use it with other effects, especially 3D effects, it is required to wrap slide’s content with a <div className="swiper-slide-transform"> element. And if you use any custom styles on slides (like background colors, border radius, border, etc.), they should be set on
|
cubeEffect
Set cube effect parameters.
Name | Type | Default | Description | Example |
---|---|---|---|
| any | no default | Object with Cube-effect parameters
|
direction
Set the direction for Swipoer sliders.
Name | Type | Default | Description | Example |
---|---|---|---|
| horizontal | vertical | horizontal | Can be |
edgeSwipeDetection
Name | Type | Default | Description | Example |
---|---|---|---|
| string | boolean | false | Enable to release Swiper events for swipe-back work in app. If set to |
edgeSwipeThreshold
Area (in px) from left edge of the screen to release touch events.
Name | Type | Default | Description | Example |
---|---|---|---|
| number | 20 | Area (in px) from left edge of the screen to release touch events for swipe-back in app. |
effect
Set slide transition effects.
Name | Type | Default | Description | Example |
---|---|---|---|
| string | slide | Transition effect. Can be |
enabled
Control if a Swiper slideshow is initially enabled.
Name | Type | Default | Description | Example |
---|---|---|---|
| boolean | true | Whether Swiper initially enabled. When Swiper is disabled, it will hide all navigation elements and won’t respond to any events and interactions. |
eventsPrefix
Cntrol event name prefix for all Swiper DOM events.
Name | Type | Default | Description | Example |
---|---|---|---|
| string | swiper | Event name prefix for all DOM events emitted by Swiper Element. |
fadeEffect
The Fade Effect module in SwiperJS creates a smooth transition between each slide. Instead of sliding or sliding the slides like other effects do, the transition causes them to fade out and the next slide to fade in.
Find all available configurable settings with Fade Effect in section Modules. |
Find below how to set Fade effect parameters.
Name | Type | Default | Description | Example |
---|---|---|---|
| any | no default | The Fade Effect module in SwiperJS creates a smooth transition between each slide. Instead of sliding or sliding the slides like other effects do, the transition causes them to fade out and the next slide to fade in.
|
flipEffect
The Flip Effect module in SwiperJS creates a special transition effect between individual slides. It gives the impression that the slides are being turned like cards.
Find all available configurable settings with Flip Effect in section Modules. |
Find below how to set Flip effect parameters.
Name | Type | Default | Description | Example |
---|---|---|---|
| any | no default | Object with Flip-effect parameters
|
focusableElements
Set CSS selector for focusable elements.
Name | Type | Default | Description | Example |
---|---|---|---|
| string | input | select | option | textarea | button | video | label | CSS selector for focusable elements. Swiping will be disabled on such elements if they are focused. |
followFinger
Set slider animated only when you release it.
Name | Type | Default | Description | Example |
---|---|---|---|
| boolean | true | If disabled, then slider will be animated only when you release it, it will not move while you hold your finger on it. |
freeMode
The Free Mode module gives users a more fluid and interactive sliding experience.
Find below how to set Free Mode parameters.
Name | Type | Default | Description | Example |
---|---|---|---|
| any | no default | Enables free mode functionality. Object with free mode parameters or boolean
|
grabCursor
Improve desktop usability by setting the grab cursor when hover on Swiper.
Name | Type | Default | Description | Example |
---|---|---|---|
| boolean | false | This option may a little improve desktop usability. If |
grid
The Grid module in SwiperJS allows to create multi-row sliders, effectively arranging slides into a grid-like structure.
Find below how to set Grid parameters to enable a multirow slider.
Name | Type | Default | Description | Example |
---|---|---|---|
| any | no default | Object with grid parameters to enable multirow slider.
|
hashNavigation
Hash navigation is intended to have a link to specific slide that allows to load a page with specific slide opened.
Find below how to set Hash Navigation parameters.
Name | Type | Default | Description | Example |
---|---|---|---|
| any | no default | Enables hash url navigation for slides. Object with hash navigation parameters or boolean
|
height
Force Swiper height.
Name | Type | Default | Description | Example | ||
---|---|---|---|---|---|
height | null | number | null | 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
|
history
The History (Navigation) module in SwiperJS allows you to integrate Swiper with history of the browser. This means, when users navigate between slides in a Swiper, the browser’s URL will be updated to reflect the current slide.
Find all available configurable settings with History Navigation in section [Mdules]. |
Find below how to set History Navigation parameters.
Name | Type | Default | Description | Example |
---|---|---|---|
| any | no default | Enables history push state where every slide will have its own url. In this parameter you have to specify main slides url like Object with history navigation parameters or boolean
|
init
Specify, if Swiper should be initialised automatically.
Name | Type | Default | Description | Example |
---|---|---|---|
| boolean | true | Whether Swiper should be initialised automatically when you create an instance. If disabled, then you need to init it manually by calling |
initialSlide
Set the index number of the initial slide.
Name | Type | Default | Description | Example |
---|---|---|---|
| number | 0 | Index number of the initial slide. |
injectStyles
Inject text styles to the shadow DOM.
Name | Type | Default | Description | Example |
---|---|---|---|
| string[] | no default | Inject text styles to the shadow DOM. Only for usage with Swiper Element. |
injectStylesUrls
Inject styles `<link>`s to the shadow DOM.
Name | Type | Default | Description | Example |
---|---|---|---|
| string[] | no default | Inject styles `<link>`s to the shadow DOM. Only for usage with Swiper Element. |
keyboard
The Keyboard (Control module) in SwiperJS enables navigation through slides using the keyboard.
Find all available configurable settings with Keyboard Control in section [Mdules]. |
Find below how to set Keyboard Control parameters, to enable or disable the navigation through slides using keyboard.
Name | Type | Default | Description | Example |
---|---|---|---|
| any | no default | Enables navigation through slides using keyboard. Object with keyboard parameters or boolean
|
Options L - O
List of available Swiper parameters (properties) alphabetically ordered from L to O. Find parameter settings also with the Swiper Documentation.
Lazy Loading
The Lazy Loading module in SwiperJS controls the lazy loading of images within a swiper. Lazy loading means images are not loaded until they scroll into the browser’s visible area. Using the module increases loading speed, especially for websites with many images, and thus improves the user experience.
Find all available configurable settings with Lazy Loading in section [Mdules]. |
Find the available options for lazy loading below.
lazyPreloadPrevNext
Number of next and previous slides to be preloaded.
Name | Type | Default | Description |
---|---|---|---|
| number | 0 | Number of next and previous slides to preload. Only applicable if using lazy loading. |
lazyPreloaderClass
Set CSS class name of lazy preloader.
Name | Type | Default | Description |
---|---|---|---|
| string | swiper-lazy-preloader | CSS class name of lazy preloader. |
longSwipes
Enable or disable long swipes.
Name | Type | Default | Description |
---|---|---|---|
| boolean | true | Set to |
longSwipesMs
Set the minimal duration (in ms) to trigger long swipes.
Name | Type | Default | Description |
---|---|---|---|
| number | 300 | Minimal duration (in ms) to trigger swipe to next/previous slide during long swipes. |
longSwipesRatio
Set the ratio to trigger swipe to next/previous slide during long swipes.
Name | Type | Default | Description |
---|---|---|---|
| number | 0.5 | Ratio to trigger swipe to next/previous slide during long swipes. |
loop
Enable or disable continuous loop mode.
Name | Type | Default | Description |
---|---|---|---|
| boolean | false | Set to Because of nature of how the loop mode works (it will rearrange slides), total number of slides must be:
|
loopAddBlankSlides
Add blank slides if you use Grid or slidesPerGroup
on total amount of slides is not even to slidesPerGroup
.
Name | Type | Default | Description |
---|---|---|---|
| boolean | true | Automatically adds blank slides if you use Grid or |
loopAdditionalSlides
Allows to increase amount of looped slides.
Name | Type | Default | Description |
---|---|---|---|
| number | 0 | Allows to increase amount of looped slides. |
loopPreventsSliding
Set slideNext \| slidePrev to do nothing while slider is animating in loop mode.
Name | Type | Default | Description |
---|---|---|---|
| boolean | true | If enabled then slideNext/Prev will do nothing while slider is animating in loop mode. |
maxBackfaceHiddenSlides
Reduce visual flicker in Apple’s Safari Browser.
Name | Type | Default | Description | ||
---|---|---|---|---|---|
| number | 10 | If total number of slides less than specified here value, then Swiper will enable
|
mousewheel
The Mousewheel Control module in SwiperJS enables users to navigate through the slides of a SwiperJS instance using their mouse wheel.
Find all available configurable settings with Mousewheel Control in section [Mdules]. |
Find the available options for mousewheel control below to enables or disable navigation through slides using mouse wheel.
Name | Type | Default | Description |
---|---|---|---|
| any | no defaults | Enables navigation through slides using mouse wheel. Object with mousewheel parameters or boolean
|
navigation
The Pagination module in SwiperJS is a powerful tool that allows you to add visual indicators (like buttons) to a SwiperJS slide. The navigation elements make it clear to users how many slides there are and which slide they are currently viewing.
Find all available configurable settings with Navigation in section [Mdules]. |
Find the available options for navigation below to enable and configure the navigation (module).
Name | Type | Default | Description |
---|---|---|---|
| any | no defaults | Object with navigation parameters or boolean
|
nested
Control Swiper for correct touch events interception.
Name | Type | Default | Description |
---|---|---|---|
| boolean | false | Set to |
noSwiping
Control no swiping on elements specified by (CSS) noSwipingClass
.
Name | Type | Default | Description |
---|---|---|---|
| boolean | true | Enable/disable swiping on elements matched to class specified in |
noSwipingClass
Specify (CSS) elements to disable swiping on.
Name | Type | Default | Description |
---|---|---|---|
| string | swiper-no-swiping | Specify |
noSwipingSelector
Specify (CSS) elements to disable swiping on.
Name | Type | Default | Description |
---|---|---|---|
| string | no defaults | Can be used instead of |
normalizeSlideIndex
Normalize slide index.
Name | Type | Default | Description |
---|---|---|---|
| boolean | true | Normalize slide index. |
observeParents
Configure to watch Mutations for Swiper parent elements.
Name | Type | Default | Description |
---|---|---|---|
| boolean | false | Set to |
observeSlideChildren
Configure to watch Mutations for Swiper slide child elements.
Name | Type | Default | Description |
---|---|---|---|
| boolean | false | Set to |
observer
Enable a Mutation Observer on Swiper and its elements.
Name | Type | Default | Description |
---|---|---|---|
| boolean | false | Set to |
on
Register event handlers.
Name | Type | Default | Description |
---|---|---|---|
| object | no defaults | Register event handlers.
|
onAny
Register event handlers on all events.
Name | Type | Default | Description |
---|---|---|---|
| function(handler) | no defaults | Add event listener that will be fired on all events.
|
oneWayMovement
Configure swipe slides only forward (one-way) regardless of swipe direction.
Name | Type | Default | Description |
---|---|---|---|
'oneWayMovement' | boolean | false | When enabled, will swipe slides only forward (one-way) regardless of swipe direction. |
Options P - S
List of available Swiper parameters (properties) alphabetically ordered from P to S. Find parameter settings also with the Swiper Documentation.
pagination
The Pagination module in SwiperJS is a powerful tool that allows you to add visual indicators (like buttons) to a SwiperJS slide. The navigation elements make it clear to users how many slides there are and which slide they are currently viewing.
Find all available configurable settings with Pagination in section Modules. |
Find below an example how to configure the Pagination module for a SwiperJS slider.
Name | Type | Default | Description |
---|---|---|---|
| any | no defaults | Object with pagination parameters or boolean
|
parallax
The Parallax module supports parallax transition effects for SwiperJS silder slides and nested elements.
Configure parallax effect for a swipe slider.
Name | Type | Default | Description |
---|---|---|---|
| any | no defaults | Object with parallax parameters or boolean
|
passiveListeners
Configure passive event listeners.
Name | Type | Default | Description |
---|---|---|---|
| boolean | true | Passive event listeners will be used by default where possible to improve scrolling performance on mobile devices. But if you need to use |
preventClicks
Prevent unwanted clicks on links during swiping.
Name | Type | Default | Description |
---|---|---|---|
| boolean | true | Set to |
preventClicksPropagation
Stop click event propagation on links during swiping.
Name | Type | Default | Description |
---|---|---|---|
| boolean | true | Set to |
preventInteractionOnTransition
Allow to change slides by swiping or navigation \| pagination buttons during transition.
Name | Type | Default | Description |
---|---|---|---|
| boolean | false | When enabled it won’t allow to change slides by swiping or navigation/pagination buttons during transition. |
resistance
Enable or disable resistant bounds.
Name | Type | Default | Description |
---|---|---|---|
| boolean | true | Set to |
resistanceRatio
Control resistance ratio.
Name | Type | Default | Description |
---|---|---|---|
| number | 0.85 | This option allows you to control resistance ratio. |
resizeObserver
Configure ResizeObserver (if supported by browser) on swiper container to detect container resize.
Name | Type | Default | Description |
---|---|---|---|
| boolean | true | When enabled it will use ResizeObserver (if supported by browser) on swiper container to detect container resize (instead of watching for window resize). |
rewind
Enable rewind mode.
Name | Type | Default | Description | ||
---|---|---|---|---|---|
| boolean | false | Set to
|
roundLengths
Enable to round values of slides width and height to prevent blurry texts on usual resolution screens.
Name | Type | Default | Description |
---|---|---|---|
| boolean | false | Set to |
runCallbacksOnInit
Fire Transition \| SlideChange \| Start \| End events on swiper initialization.
Name | Type | Default | Description |
---|---|---|---|
| boolean | true | 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. |
scrollbar
The Scrollbar module in SwiperJS is a powerful tool that enhances user interaction and provides visual feedback within a SwiperJS slider.
Find below how to configure scrollbar parameters to enable with default settings.
Name | Type | Default | Description |
---|---|---|---|
| any | no defaults | Object with scrollbar parameters or boolean
|
setWrapperSize
Set width \| height on swiper wrapper.
Name | Type | Default | Description |
---|---|---|---|
| boolean | false | 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. |
shortSwipes
Disable short swipes.
Name | Type | Default | Description |
---|---|---|---|
| boolean | true | Set to |
simulateTouch
Enable or disable Swiper mouse events like touch events.
Name | Type | Default | Description |
---|---|---|---|
| boolean | true | If |
slideActiveClass
Set CSS class name of the active slide.
Name | Type | Default | Description | ||
---|---|---|---|---|---|
| string | swiper-slide-active | CSS class name of currently active slide.
|
slideBlankClass
Configre CSS class name blank slides.
Name | Type | Default | Description | ||
---|---|---|---|---|---|
| string | swiper-slide-blank | CSS class name of the blank slide added by the loop mode when
|
slideClass
Configre CSS class name for blank slides.
Name | Type | Default | Description | ||
---|---|---|---|---|---|
| string | swiper-slide | CSS class name of swiper slides.
|
slideFullyVisibleClass
Configre CSS class name for blank slides.
Name | Type | Default | Description | ||
---|---|---|---|---|---|
| string | swiper-slide-fully-visible | CSS class name of fully (when whole slide is in the viewport) visible slide.
|
slideNextClass
Configre CSS class name of the slide which is right after the active slide.
Name | Type | Default | Description | ||
---|---|---|---|---|---|
| string | swiper-slide-next | CSS class name of slide which is right after currently active slide.
|
slidePrevClass
Configre CSS class name of the slide which is right before the active slide.
Name | Type | Default | Description | ||
---|---|---|---|---|---|
| string | swiper-slide-prev | CSS class name of slide which is right before currently active slide.
|
slideToClickedSlide
Enable click on any slide to trigger a transition.
Name | Type | Default | Description |
---|---|---|---|
| boolean | false | Set to |
slideVisibleClass
Set the CSS class name of the currently active or partially visible slide.
Name | Type | Default | Description | ||
---|---|---|---|---|---|
| string | swiper-slide-visible | CSS class name of the currently active or partially visible slide.
|
slidesOffsetAfter
Set additional slide offset (in px) at the end of the container after all slides configured.
Name | Type | Default | Description |
---|---|---|---|
| number | 0 | Add additional slide offset (in px) at the end of the container after all slides configured. |
slidesOffsetBefore
Set additional slide offset (in px) in the beginning of the container before all slides configured.
Name | Type | Default | Description |
---|---|---|---|
| number | 0 | Add (in px) additional slide offset (in px) in the beginning of the container before all slides configured. |
slidesPerGroup
Set numbers of slides for group sliding.
Name | Type | Default | Description |
---|---|---|---|
| number | 1 | Set numbers of slides for group sliding. Useful to use with slidesPerView Parameter set larger than 1. |
slidesPerGroupAuto
Set number of slides for group sliding to skip all slides in view on .slideNext()
\| .slidePrev()
methods calls, on Navigation button clicks in autoplay.
Name | Type | Default | Description |
---|---|---|---|
| boolean | false | This param intended to be used only with |
slidesPerGroupSkip
Set number of slides for group sliding to skip slides.
Name | Type | Default | Description |
---|---|---|---|
| number | 0 | The parameter works in the following way: If If |
slidesPerView
Set the number of slides visible per view on a slider.
Name | Type | Default | Description | ||
---|---|---|---|---|---|
| number | auto | 1 | Number of slides visible per view on a slider.
|
spaceBetween
Set Gutters (space) in between the slides in px.
Name | Type | Default | Description | ||
---|---|---|---|---|---|
| string | number | 0 | Set Gutters (space) in between the slides in px.
|
speed
Set Duration of transition between slides in ms.
Name | Type | Default | Description |
---|---|---|---|
| number | 300 | Duration of transition between slides in ms. |
swipeHandler
Set the CSS selector \| HTML element for swiping of the the swiper container.
Name | Type | Default | Description |
---|---|---|---|
| any | null | String with CSS selector | HTML element for swiping of the the swiper container. |
swiperElementNodeName
Set the name of the swiper element node name.
Name | Type | Default | Description |
---|---|---|---|
| string | swiper-container | The name of the swiper element node name. Used for detecting web component rendering. |
Options T - Z
List of available Swiper parameters (properties) alphabetically ordered from T to Z. Find parameter settings also with the Swiper Documentation.
threshold
Set the threshold value in px then swiper will not move.
Name | Type | Default | Description |
---|---|---|---|
| number | 5 | Threshold value in px. If touch distance will be lower than this value then swiper will not move. |
thumbs
The Thumbs module enables to create a thumbnail navigation for SliderJS sliders.
Find below how to enable the thumbs module and set the thumbs parameters.
Name | Type | Default | Description |
---|---|---|---|
| any | no defaults | Object with thumbs component parameters for thumb image navigation.
|
touchAngle
Set Angle in degrees to trigger touch move.
Name | Type | Default | Description |
---|---|---|---|
| number | 45 | Angle in degrees to trigger touch move. |
touchEventsTarget
Set the target element to listen on touch events.
Name | Type | Default | Description |
---|---|---|---|
| container | wrapper | wrapper | Target element to listen on touch events. Can be container to listen for touch events on the swiper container or wrapper to listen for touch events on the swiper wrapper. |
touchMoveStopPropagation
Enable to stop the propagation of touchmove.
Name | Type | Default | Description |
---|---|---|---|
| boolean | false | If enabled, then propagation of touchmove will be stopped. |
touchRatio
Set the touch ratio.
Name | Type | Default | Description |
---|---|---|---|
| number | 1 | Touch ratio |
touchReleaseOnEdges
Enable touch events on slider edge positions for page scrolling.
Name | Type | Default | Description |
---|---|---|---|
| boolean | false | Enable to release touch events on slider edge position (beginning, end) to allow for further page scrolling. This feature works only with touch events (and not pointer events), so it will work on iOS * or *Android devices (mobiles) and not work on Windows (desktp) devices with pointer events. Also threshold parameter must be set to 0. |
touchStartForcePreventDefault
Force to prevent default for touchstart
or pointerdown
events.
Name | Type | Default | Description |
---|---|---|---|
| boolean | false | Force to prevent default for |
touchStartPreventDefault
Enable prevent default for touchstart
or pointerdown
events.
Name | Type | Default | Description |
---|---|---|---|
| boolean | true | If set |
uniqueNavElements
Disable navigation element parameters passed as a string like .pagination.
Name | Type | Default | Description |
---|---|---|---|
| boolean | true | When enabled (by default) and navigation element 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. |
updateOnWindowResize
Disable the recalculation of slide positions on window resize for desktops or orientation change on mobiles.
Name | Type | Default | Description |
---|---|---|---|
| boolean | true | Swiper will recalculate slides position on window resize (desktops) or orientation change (on mobiles). |
url
Required for active slide detection when rendered on server-side and history enabled.
Name | Type | Default | Description |
---|---|---|---|
| null | string | null | Required for active slide detection when rendered on server-side and history enabled. |
userAgent
Setting the userAgent string is required for browser or device detection when swiper is rendered on server-side.
Name | Type | Default | Description |
---|---|---|---|
| null | string | null | userAgent string. Required for browser | device detection when swiper is rendered on server-side. |
virtual
The Virtual Slides module allows you to keep the required number of slides in the DOM. The module is very useful in terms of performance and memory issues if you have a lot of slides, especially slides with heavyweight DOM trees or images.
Find all available configurable settings with Virtual Slides in section [Mdules]. |
Find below how to enable and configures the virtual slides functionality.
Name | Type | Default | Description |
---|---|---|---|
'virtual' | any | no defaults | Enables virtual slides functionality. Object with virtual slides parameters or boolean
|
virtualTranslate
Useful when you need to create custom slide transitions.
Name | Type | Default | Description | ||
---|---|---|---|---|---|
| boolean | false | If enabled, the swiper will be operated as usual, but will not move and real CSS3 transform translate values on wrapper will not be set.
|
watchOverflow
When enabled, the swiper will be disabled and hide navigation buttons in case there are not enough slides for sliding.
Name | Type | Default | Description |
---|---|---|---|
| boolean | true | When enabled, Swiper will be disabled and hide navigation buttons in case there are not enough slides for sliding. |
watchSlidesProgress
When enabled, the swiper will be disabled and hide navigation buttons in case there are not enough slides for sliding.
Name | Type | Default | Description | ||
---|---|---|---|---|---|
| boolean | false | Enable this feature to calculate each slides progress and visibility.
|
width
Force the swiper width (in px).
Name | Type | Default | Description | ||
---|---|---|---|---|---|
| null | number | null | Parameter allows to force the swiper width (in px).
|
wrapperClass
Set the CSS class name of the slides wrapper.
Name | Type | Default | Description | ||
---|---|---|---|---|---|
| string | swiper-wrapper | CSS class name of the slides wrapper.
|
zoom
Enables zooming functionality.
Name | Type | Default | Description |
---|---|---|---|
| any | no defaults | Enables zooming functionality. Object with zoom parameters or boolean
|
Instance Properties A - M
After slider initialization, the instance variable comes with helpful properties (slider parameters) set. See the the const swiper (variable) in the examples from above.
List of available Swiper parameters (properties) alphabetically ordered from A to M. Find parameter settings also with the Swiper Documentation.
activeIndex
Index number of the active slide.
Name | Type | Description | ||
---|---|---|---|---|
| number | Index number of the active slide.
|
allowSlideNext
Set the ability on sliding to the next slides by assigning false
\| true
to this property.
Name | Type | Description |
---|---|---|
| boolean | Disable | Enable ability to slide to the next slides by assigning |
allowSlidePrev
Set the ability on sliding to the previous slides by assigning false
\| true
to this property.
Name | Type | Description |
---|---|---|
| boolean | Disable | Enable ability to slide to the previous slides by assigning |
allowTouchMove
Set the ability move slider by grabbing it with mouse or by touching it with finger (on touch screens) by assigning false
\| true
to this property.
Name | Type | Description |
---|---|---|
| boolean | Disable | Enable ability move slider by grabbing it with mouse or by touching it with finger (on touch screens) by assigning |
animating
Is set to true
if swiper is in transition.
Name | Type | Description |
---|---|---|
| boolean | Is set to |
animating
Is set to true
if swiper is in transition.
Name | Type | Description |
---|---|---|
| any | Set auto playing behaviour for a slide show. |
cardsEffect
Object with Cards-effect parameters.
Name | Type | Description |
---|---|---|
| any | Object with Cards-effect parameters. |
clickedIndex
Index number of last clicked slide.
Name | Type | Description |
---|---|---|
'clickedIndex' | number | Index number of last clicked slide. |
clickedSlide
Link to last clicked slide (HTML Element).
Name | Type | Description |
---|---|---|
| HTML Element | Link to last clicked slide (HTML Element). |
controller
Object with controller parameters or boolean true
to enable with default settings.
Name | Type | Description |
---|---|---|
| any | Object with controller parameters or boolean |
coverflowEffect
Object with Coverflow-effect parameters.
Name | Type | Description ` |
---|---|---|
coverflowEffect ` | any | Object with Coverflow-effect parameters. |
creativeEffect
Object with Creative-effect parameters.
Name | Type | Description |
---|---|---|
| any | Object with Creative-effect parameters. |
cubeEffect
Object with Cube-effect parameters.
Name | Type | Description |
---|---|---|
| any | Object with Cube-effect parameters. |
defaults
Object with Swiper default options.
Name | Type | Description |
---|---|---|
| any | Swiper default options. |
el
Contains the Slider container HTML element.
Name | Type | Description |
---|---|---|
| HTML Element | Slider container HTML element. |
extendedDefaults
Object with global Swiper extended options.
Name | Type | Description |
---|---|---|
| any | Object with global Swiper extended options. |
fadeEffect
Object with Fade-effect parameters.
Name | Type | Description |
---|---|---|
| any | Object with Fade-effect parameters. |
flipEffect
Object with Flip-effect parameters.
Name | Type | Description |
---|---|---|
| any | Object with Flip-effect parameters. |
freeMode
Object with free mode parameters or boolean true
if enabled with default settings.
Name | Type | Description |
---|---|---|
| any | Object with free mode parameters or boolean |
hashNavigation
Object with hash navigation parameters or boolean true
if enabled with default settings.
Name | Type | Description |
---|---|---|
| any | Object with hash navigation parameters or boolean |
height
Is set to the height of the swiper container.
Name | Type | Description |
---|---|---|
| number | Is set to the height of the swiper container. |
history
Object with history parameters.
Name | Type | Description |
---|---|---|
| any | Object with history parameters. |
isBeginning
Is set to true
if slider on most left|top position.
Name | Type | Description |
---|---|---|
| boolean | Is set to |
isEnd
Is set to true
if slider on most right/bottom position.
Name | Type | Description |
---|---|---|
| boolean | Is set to |
isLocked
Is set to true
if slide is locked (watchOverflow
) and slides can not be accessed, e.g. when amount of slides is less than slides per view.
Name | Type | Description |
---|---|---|
| boolean | Is set to |
keyboard
Object with keyboard parameters or boolean true
if enabled with default settings.
Name | Type | Description |
---|---|---|
| any | Object with keyboard parameters or boolean |
mousewheel
Object with mousewheel parameters or boolean true
ìf enabled with default settings.
Name | Type | Description |
---|---|---|
| any | Object with mousewheel parameters or boolean |
Instance Properties N - Z
After slider initialization, the instance variable comes with helpful properties (slider parameters) set. See the the const swiper (variable) in the examples from above.
List of available Swiper parameters (properties) alphabetically ordered from N to Z. Find parameter settings also with the Swiper Documentation.
navigation
Object with navigation parameters or boolean true
if enabled with default settings.
Name | Type | Description |
---|---|---|
| any | Object with navigation parameters or boolean |
originalParams
Object with original initialization parameters
Name | Type | Description |
---|---|---|
| any | Object with original initialization parameters |
pagination
Object with pagination parameters or boolean true
if enabled with default settings.
Name | Type | Description |
---|---|---|
| any | Object with pagination parameters or boolean |
parallax
Object with parallax parameters or boolean true
if enabled with default settings.
Name | Type | Description |
---|---|---|
| any | Object with parallax parameters or boolean |
params
Object with passed initialization parameters.
Name | Type | Description |
---|---|---|
| any | Object with passed initialization parameters. |
previousIndex
Is set to index number of previously active slide.
Name | Type | Description |
---|---|---|
| number | Is set to index number of previously active slide. |
progress
Current progress of wrapper translate (from 0 to 1).
Name | Type | Description |
---|---|---|
| number | Current progress of wrapper translate (from 0 to 1). |
realIndex
Index number of currently active slide considering rearranged slides in loop mode.
Name | Type | Description |
---|---|---|
| number | Index number of currently active slide considering rearranged slides in loop mode. |
scrollbar
Object with scrollbar parameters or boolean true
if enabled with default settings.
Name | Type | Description |
---|---|---|
| any | Object with scrollbar parameters or boolean |
slides
Array of slides HTML elements. To get specific slide HTML Element use swiper.slides[1]
Name | Type | Description |
---|---|---|
| HTML Element[] | Array of slides HTML elements. To get specific slide HTML Element use |
slidesEl
Swiper wrapper HTML element.
Name | Type | Description |
---|---|---|
| HTML Element | Swiper wrapper HTML element. |
slidesGrid
Array of slides grid elements.
Name | Type | Description |
---|---|---|
| number[] | Array of slides grid elements. |
slidesSizesGrid
Array of widths for all slides elements.
Name | Type | Description |
---|---|---|
| number[] | Array of widths for all slides elements. |
snapGrid
Array of all slides snap grid elements.
Name | Type | Description |
---|---|---|
| number[] | Array of all slides snap grid elements. |
snapIndex
Index number of current snap in snapGrid
.
Name | Type | Description |
---|---|---|
| number | Index number of current snap in |
swipeDirection
Strings that reflect the direction of sliding.
Name | Type | Description |
---|---|---|
| prev | next | Strings that reflect the direction of sliding. |
thumbs
Object with thumbs component parameters for thumb image navigation.
Name | Type | Description |
---|---|---|
| any | Object with thumbs component parameters for thumb image navigation. |
touches
Object with touch event properties.
Name | Type | Description |
---|---|---|
| object | Object with the following touch event properties:
|
translate
Is set to current value of wrapper translate.
Name | Type | Description |
---|---|---|
| number | Is set to current value of wrapper translate. |
virtual
Object with virtual slides settings.
Name | Type | Description |
---|---|---|
| any | Object with virtual slides settings. |
width
Set to width of the swiper container.
Name | Type | Description |
---|---|---|
| number | Set to width of the swiper container. |
wrapperEl
Swiper wrapper HTML element.
Name | Type | Description |
---|---|---|
| HTML Element | Swiper wrapper HTML element. |
zoom
Object with zoom parameters or boolean true
if enabled with default settings.
Name | Type | Description |
---|---|---|
| any | Object with zoom parameters or boolean |
Modules
SwiperJS modules are extensions that extend the functionality of the core SwiperJS system. They offer additional and advanced features and customization options beyond the basic functions of SwiperJS sliders.
Find available SwiperJS module descriptions also with the Swiper Documentation. |
- Additional features
-
Modules can be used when navigation, pagination, a scroll bar, or an effect, such as a zoom effect, is required. A suitable module already exists for many additional functions.
- Customizatiion
-
Modules allow detailed customization of a slideshow’s look and behavior and enable the adaptation of sliders to individual needs.
For using SwiperJS in the web browser or for J1 template projects, all modules are already integrated* into the JS and CSS resources as bundle versions and can be used immediately. It is advisable to configure only the required modules to keep the code and configuration of a SwiperJS slider compact and clear. |
Name | Description | Example |
---|---|
Enable and configure Accessibility (a11y) module features of SwiperJS available for screen readers and other assistive technologies.
| |
The Controller module allows to synchronize the movement of multiple slider instances.
| |
The Cards Effect module in SwiperJS adds a visually appealing, card-like sliding animation for transitions between slides in a SwiperJS slider instance.
| |
The Coverflow Effect module for SwiperJS creates a three-dimensional, fan-like effect for the slides in a Swiper container. This effect is inspired by the Coverflow view that you can see, for example, when selecting albums in iTunes.
| |
The creative effect module in SwiperJS generates creative and engaging visual effects for the slides in a Swiper. The module allows for various custom transformations to animate the slides dynamically as they transition between each slide.
| |
The Cube Effect module in SwiperJS adds a 3D cube-like rotation effect to the transitions between slides in a SwiperJS slider instance.
| |
The Fade Effect module in SwiperJS creates a smooth transition between each slide. Instead of sliding or sliding the slides like other effects do, the transition causes them to fade out and the next slide to fade in.
| |
The Flip Effect module in SwiperJS creates a special transition effect between individual slides. It gives the impression that the slides are being turned like cards.
| |
The Free Mode module gives users a more fluid and interactive sliding experience.
| |
The Grid module in SwiperJS allows to create multi-row sliders, effectively arranging slides into a grid-like structure.
| |
Hash navigation is intended to have a link to specific slide that allows to load a page with specific slide opened.
| |
The History (Navigation) module in SwiperJS allows you to integrate Swiper with history of the browser. This means, when users navigate between slides in a Swiper, the browser’s URL will be updated to reflect the current slide. Object with history navigation parameters or boolean
| |
The Keyboard Control module in SwiperJS enables navigation through slides using the keyboard.
| |
The Lazy Loading module in SwiperJS controls the lazy loading of images within a swiper. Lazy loading means images are not loaded until they scroll into the browser’s visible area. Using the module increases loading speed, especially for websites with many images, and thus improves the user experience. | |
The Manipulation module adds useful methods to SwiperJS for manipulating slides. The module provides methods for dynamically adding, removing, and rearranging slides within a SwiperJS slider. | |
The Mousewheel Control module in SwiperJS enables users to navigate through the slides of a SwiperJS instance using their mouse wheel.
| |
The Pagination module in SwiperJS is a powerful tool for adding visual indicators (like buttons) to a SwiperJS slide. The navigation elements make it clear to users how many slides they view and which ones they view.
| |
The Parallax module supports parallax transition effects for SwiperJS silder slides and nested elements.
| |
The Scrollbar module in SwiperJS is a powerful tool that enhances user interaction and provides visual feedback within a SwiperJS slider.
| |
The Thumbs module enables to create a thumbnail navigation for SliderJS sliders.
| |
The Virtual Slides module allows you to keep the required number of slides in the DOM. The module is very useful in terms of performance and memory issues if you have a lot of slides, especially slides with heavyweight DOM trees or images.
|
Accessibility (a11y)
Enable and configure Accessibility (a11y) module features of SwiperJS available for screen readers and other assistive technologies. By using the parameter and its options, you can significantly enhance the accessibility for users with disabilities:
- Keyboard Navigation
-
Enables users to navigate slides using keyboard arrows.
- Screen Reader Support
-
Provides meaningful information to screen readers about the slider, such as the number of slides and the current slide.
- Customizable Messages
-
Allows you to provide custom messages for screen readers, improving user experience.
Parameters
Find all parameters available for the Accessibility (a11y) module.
Name | Type | Default | Description | Example |
---|---|---|---|
| null | string | null | Message for screen readers for outer swiper container. |
| null | string | null | Value of the role attribute to be set on the swiper container. |
| null | string | null | Message for screen readers describing the role of outer swiper container. |
| boolean |
| Enables the Accessibility Module (a11y). |
| string | This is the first slide | Message for screen readers for previous button when swiper is on first slide. |
| null | string | number | null | Value of the id attribute to be set on swiper-wrapper. If set to |
| null | string | null | Message for screen readers describing the role of a slide element. |
| string | This is the last slide | Message for screen readers for next button when swiper is on last slide. |
| string | Next slide | Message for screen readers for the next button. |
| string | swiper-notification | CSS class name of A11y notification. |
| string | Go to slide {{index}} | Message for screen readers for single pagination bullet. |
| string | Previous slide | Message for screen readers for the previous button. |
| boolean |
| Enables scrolling to the slide that has been focused. |
| string | {{index}} | {{slidesLength}} | Message for screen readers describing the label of the slide element. |
| string | group | Value of swiper slide role attribute. |
Autoplay
The Autoplay module in SwiperJS is a powerful feature that allows you to automatically transition between slides in your slider at a specified interval. Here’s a breakdown of its key functionalities:
- Automatic Slide Transitions
-
The primary function is to automatically move the slider to the next slide after a defined delay.
- Customization
-
You can extensively customize the autoplay behavior:
-
Delay: Control the time interval between each slide transition.
-
Disable on Interaction: Stop autoplay when the user interacts with the slider (e.g., swiping, clicking).
-
Reverse Direction: Change the direction of autoplay (from right to left or vice versa).
-
Disable on Interaction: Stop autoplay when the user interacts with the slider.
-
Parameters
Find all Parameters available for the Autoplay module.
Name | Type | Default | Description | Example | ||
---|---|---|---|---|---|
| number | 3000 | Delay between transitions (in ms). If this parameter is not specified, auto play will be disabled. If you need to specify different delay for specific slides you can do it by using
| ||
| boolean |
| Set to | ||
| boolean |
| When enabled, autoplay will be paused on pointer (mouse) enter over Swiper container. | ||
| boolean |
| Enables autoplay in reverse direction. | ||
| boolean |
| Enable this parameter and autoplay is stopped when the last slide is reached.
| ||
| boolean |
| When enabled autoplay will wait for wrapper transition to continue. Can be disabled in case of using Virtual Translate when your slider may not have transitions. |
Properties
Find all Properties available for the Autoplay module.
Name | Type | Description |
---|---|---|
| boolean | Indicate whether autoplay is paused. |
| boolean | Indicate whether autoplay is enabled and running. |
| number | If autoplay is paused, it contains the time left (in ms) before transition starts to next slide. |
Methods
Find all Methods available for the Autoplay module.
Name | Description |
---|---|
| Pause autoplay. |
| Resume autoplay. |
| Starts autoplay. |
| Stops autoplay. |
Find all events availalable for the
Events
Find all Events available for the Autoplay module.
All events receives swiper event data as an argument. |
autoplay
Event will be fired when slide changed with autoplay.
Usage |
---|
|
autoplayPause
Event will be fired on autoplay pause.
Usage |
---|
|
autoplayResume
Event will be fired on autoplay resume.
Usage |
---|
|
autoplayStart
Event will be fired in case autoplay has been started.
Usage |
---|
|
autoplayStop
Event will be fired when autoplay has been stopped.
Usage |
---|
|
autoplayTimeLeft
Event fires continuously while autoplay is enabled. It contains time left (in ms) before transition to next slide and percentage of the time related to autoplay delay.
Receives swiper, timeLeft, percentage event data as arguments. |
Usage |
---|
|
Controller
In SwiperJS, the Controller module allows to synchronize the movement of one or multiple slider instances. This is incredibly useful for creating complex, interconnected slider experiences. Here’s a breakdown of its key functionalities:
- Master/Slave Relationship
-
You designate one swiper instance as the master and others as slaves.
- Synchronized Slides
-
When the master swiper changes slides, the slave swipers automatically move to the corresponding position.
- Inverse Control
-
You can configure the slaves to move in the opposite direction of the master.
- By Slide or by Progress
-
Control can be based on the slide index of the master or its overall progress percentage.
Parameters
Find all parameters available for the Controller module.
Name | Type | Default | Description | Example |
---|---|---|---|
| slide | container | slide | Defines, as a string, to control another slider or (multiple sliders) slide by slide. With respect to other slider’s grid or depending on all sliders container, depending on total slider percentage. |
| any | no default | Pass another sniper instance or an array of (multiple) sniper instances that should be controlled by this swiper. Also accepts a string with a CSS selector or the HTML Element of a swiper. |
| boolean |
| If set to |
Methods
Find below available Methods for the SwiperJS Controller module.
Method | Description | Example |
---|---|
| Pass a swiper instance or an array of (multiple) instances that should be controlled by this swiper.
|
Cards Effect
The Cards Effect module in SwiperJS adds a visually appealing, card-like sliding animation for transitions between slides in a SwiperJS slider instance.
Be sure to have the parameter |
Parameters
Find all parameters available for the Cards Effect module.
Name | Type | Default | Description |
---|---|---|---|
| number | 8 | Offset distance per slide (in px). |
| number | 2 | Rotate angle per slide (in degrees). |
| boolean |
| Enables cards rotation. |
| boolean |
| Enables slides shadows. |
Coverflow Effect
Be sure to have the effect
param set to 'coverflow'
in order for this to work.
Parameters
Find all parameters available for the Coverflow Effect module.
Name | Type | Default | Description |
---|---|---|---|
| number | 100 | Depth offset in px (slides translate in Z axis). |
| number | 1 | Effect multiplier. |
| number | 50 | Slide rotate in degrees. |
| number | 1 | Slide scale effect. |
| boolean |
| Enables slides shadows. |
| number | 0 | Stretch space between slides (in px). |
Creative Effect
The creative effect module in SwiperJS generates creative and engaging visual effects for the slides in a Swiper. It allows for a variety of custom transformations to animate the slides dynamically as they transition between each slide.
Here’s a breakdown of its key features:
- Customizable Transitions
-
Allows you to define unique transformations for each slide (previous, next, and active) using properties like translate, rotate, scale, opacity, and more. This flexibility enables you to create a wide range of effects, from subtle shifts to dramatic 3D transformations.
- Precise Control
-
Offers fine-grained control over the timing and appearance of each effect by manipulating CSS properties directly. You can adjust the intensity, duration, and easing of transitions to achieve the desired visual impact.
Be sure to have the parameter |
Parameters
Find all parameters available for the SwiperJS Creative Effect module.
Name | Type | Default | Description | Example |
---|---|---|---|
| number | 1 | Limit progress/offset to amount of side slides. If |
| CreativeEffectTransform | no default | Next slide transformations. |
| boolean |
| Enable this parameter if your custom transforms require 3D transformations like |
| CreativeEffectTransform | no defaults | Previous slide transformations. Accepts object of the following type: |
| number | 1 | Allows to multiply slides transformations and opacity. |
| boolean |
| Splits shadow "opacity" per slide based on |
Cube Effect
The Cube Effect module in SwiperJS adds a 3D cube-like rotation effect to the transitions between slides in a SwiperJS slider instance.
Be sure to have the parameter |
Parameters
Find all parameters available for the Cube Effect module.
Name | Type | Default | Description |
---|---|---|---|
| boolean |
| Enables main slider shadow. |
| number | 20 | Main shadow offset in px. |
| number | 0.94 | Main shadow scale ratio. |
| boolean |
| Enables slides shadows. |
Fade Effect
The Fade Effect module in SwiperJS creates a smooth transition between each slide. Instead of sliding or sliding the slides like other effects do, the transition causes them to fade out and the next slide to fade in.
Be sure to have the Parameter |
Parameters
Find all parameters available for the Fade Effect module.
Name | Type | Default | Description |
---|---|---|---|
| boolean |
| Enables slides cross fade. |
Flip Effect
The Flip Effect module in SwiperJS adds a 3D flip animation to the slides in your slider.
Be sure to have the parameter |
Parameters
Find all parameters available for the Flip Effect module.
Name | Type | Default | Description |
---|---|---|---|
| boolean |
| Limit edge slides rotation. |
| boolean |
| Enables slides shadows. |
Free Mode
In SwiperJS, the Free Mode module allows for a more fluid and interactive sliding experience. Here’s a breakdown of its key features:
- Free Movement
-
Slides can be freely dragged and positioned anywhere within the slider container.
- Momentum
-
When the user releases the slide, it continues to move with momentum, simulating realistic inertia.
- Sticky Option
-
This optional feature snaps the slide to the nearest position when it comes to rest, providing a more controlled experience.
Parameters
Find all parameters available for the Free Mode module.
Name | Type | Default | Description |
---|---|---|---|
| boolean |
| Whether the free mode is enabled. |
| number | 0.02 | Minimum touchmove-velocity required to trigger free mode momentum. |
| boolean |
| If enabled, then slide will keep moving for a while after you release it. |
| boolean |
| Set to |
| number | 1 | Higher value produces larger momentum bounce effect. |
| number | 1 | Higher value produces larger momentum distance after you release slider. |
| number | 1 | Higher value produces larger momentum velocity after you release slider. |
| boolean |
| Set to enabled to enable snap to slides positions in free mode. |
Grid
The Grid module in SwiperJS allows you to create multi-row sliders, effectively arranging slides into a grid-like structure. Here’s a breakdown of its key features:
- Multi-row layouts
-
Define the number of rows (
grid.rows
) to control how slides are distributed within the slider. - Fill direction
-
Control how slides fill the rows:
-
grid.fill: row, Slides fill rows from left to right.
-
grid.fill: column, Slides fill columns from top to bottom.
-
Parameters
Find all parameters available for the Grid module.
Name | Type | Default | Description | Example | ||
---|---|---|---|---|---|
| row | column | column | Can be column or row. Defines how slides should fill rows, by column or by row.
| ||
| number | 1 | Number of slides rows, for multirow layout. |
Hash Navigation
Hash navigation is intended to have a link to specific slide that allows to load page with specific slide opened.
To make it work, you need to enable it by passing:
-
hashNavigation: true
parameter and adding slides hashes in -
data-hash
attribute:
<div id="swiperHashNavigation" class="swiper swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide" data-hash="slide1">Slide 1</div>
<div class="swiper-slide" data-hash="slide2">Slide 2</div>
<div class="swiper-slide" data-hash="slide3">Slide 3</div>
<div class="swiper-slide" data-hash="slide4">Slide 4</div>
<div class="swiper-slide" data-hash="slide5">Slide 5</div>
...
</div>
</div>
const swiper = new Swiper('#swiperHashNavigation', {
//enable hash navigation
hashNavigation: true
});
Parameters
Find all parameters available for the Hash Navigation module.
Name | Type | Default | Description |
---|---|---|---|
| function(swiper, hash) | no default | Designed to be used with Virtual slides when it is impossible to find slide in DOM by hash (e.g. not yet rendered). |
| boolean |
| Works in addition to hashnav to replace current url state with the new one instead of adding it to history. |
| boolean |
| Set to |
Events
Find below available Events for the SwiperJS Hash Navigation module.
hashChange
Event fired on window hash change.
Usage |
---|
|
hashSet
Event fired when swiper updates the hash.
Usage |
---|
|
History Navigation
The History Navigation module in SwiperJS allows you to integrate Swiper with history of your browser. This means, when you navigate between slides in your Swiper, the browser’s URL will be updated to reflect the current slide. This is useful for:
- Browser back/forward buttons
-
Users can navigate through the slides using their browser’s back and forward buttons, providing a familiar and intuitive user experience.
- Bookmarking specific slides
-
Users can easily bookmark a particular slide and return to it later.
- Sharing specific slides
-
Sharing the URL of a specific slide with others allows them to directly access that slide.
- SEO
-
Search engines can index individual slides and potentially this may improve your website’s search rank.
Parameters
Find all parameters available for the History Navigation module.
Name | Type | Default | Description | Example |
---|---|---|---|
| boolean |
| Enables the History Plugin. |
| boolean |
| Keep query parameters when changing browser url. |
| string | slides | URL key for slides. |
| boolean |
| Works in addition to hashnav or history to replace current url state with the new one instead of adding it to history. |
| string | empty string | swiper page root, useful to specify when you use SwiperJS history mode not on root website page. For example can be |
Keyboard Control
The Keyboard Control module in SwiperJS enables navigation through slides using the keyboard. Here’s a breakdown of its key functionalities:
- Default Keys
-
Typically uses arrow keys (left/right) to navigate between slides.
- Customizable
-
You can potentially configure it to use other keys if needed.
- Viewport Control
-
This option allows you to control whether keyboard navigation works only when the SwiperJS instance is within the viewport. This can be useful to prevent accidental navigation when the swiper is off-screen.
Parameters
Find all parameters available for the Keyboard Control module.
Name | Type | Default | Description | Example |
---|---|---|---|
| boolean |
| Set to |
| boolean |
| When enabled it will control sliders that are currently in viewport. |
| boolean |
| When enabled it will enable keyboard navigation by Page Up and Page Down keys. |
Properties
Find below available Properties for the SwiperJS Keyboard Control module.
Name | Type | Description |
---|---|---|
| boolean | Whether the keyboard control is enabled. |
Methods
Find below available Methods for the SwiperJS Keyboard Control module.
Method | Description |
---|---|
| Disable keyboard control. |
| Enable keyboard control. |
Events
Find below available Events for the SwiperJS Keyboard Control module.
keyPress
Event fired on key press.
Usage |
---|
|
Lazy Loading
Since version 9 SwiperJSdoesn’t have a specific lazy loading API, as it relies on native browser lazy loading feature. To use lazy loading, we just need to set loading="lazy"
on images and add preloader element:
<div class="swiper">
<div class="swiper-wrapper">
<!-- Lazy image -->
<div class="swiper-slide">
<img src="path/to/picture-1.jpg" loading="lazy" />
<div class="swiper-lazy-preloader"></div>
</div>
<!-- Lazy image with srcset -->
<div class="swiper-slide">
<img
src="path/to/logo-small.png"
srcset="path/to/logo-large.png 2x"
loading="lazy"
/>
<div class="swiper-lazy-preloader"></div>
</div>
</div>
</div>
As you see:
-
Lazy image must have
loading="lazy"
attribute -
Add animated preloader spinner to slide which will be removed automatically after image loaded:
<div class="swiper-lazy-preloader"></div>
Or white one for dark layout:
<div class="swiper-lazy-preloader swiper-lazy-preloader-white"></div>
Manipulation
The Manipulation module adds useful methods to SwiperJS for manipulating slides. The module provides methods for dynamically adding, removing, and rearranging slides within the slider.
It makes sense to use it only with SwiperJS Core version, amd is not intended to be used with SwiperJS Environments like React or Vue. |
Methods
Find below available Methods for the SwiperJS Manipulation module.
Method | Description | Example |
---|---|
| Add new slides to the required index. Slides could be HTML Element or HTML string with new slide or array with such slides.
|
| Add new slides to the end. Slides could be a HTML Element or HTML string with new slide or array with such slides.
|
| Add new slides to the beginning. Slides could be HTML Element or HTML string with new slide or array with such slides.
|
| Remove all slides.
|
| Remove selected slides. SlideIndex could be a number with slide index to remove or array with indexes.
|
Mousewheel Control
The Mousewheel Control module in SwiperJS enables users to navigate through the slides of a SwiperJS instance using their mouse wheel. Here’s a breakdown of its key functionalities:
- Smooth Scrolling
-
Allows for smooth and intuitive navigation through slides by scrolling the mouse wheel.
- Configurable
-
Offers options to customize mousewheel behavior, such as:
-
releaseOnEdges: Allows page scrolling when the swiper reaches the beginning or end.
-
invert: Inverts the scrolling direction e.g. for scrolling up moves to the next slide.
-
- Axis Control
-
Can be configured to restrict mousewheel scrolling to a defined axis, e.g. for only horizontal scrolling in horizontal mode.
Parameters
Find below available Parameters for the SwiperJS Mousewheel Control module.
Name | Type | Default | Description |
---|---|---|---|
| boolean |
| Set to |
| string | container | String with CSS selector or HTML element of the container accepting mousewheel events. By default it is swiper. |
| boolean |
| Set to |
| boolean |
| Set to |
| string | swiper-no-mousewheel | Scrolling on elements with this class will be ignored. |
| boolean |
| Set to |
| number | 1 | Multiplier of mousewheel data, allows to tweak mouse wheel sensitivity. |
| null | number | null | Minimum mousewheel scroll delta to trigger swiper slide change. |
| null | number | null | Minimum mousewheel scroll time delta (in ms) to trigger swiper slide change. |
Properties
Find below available Properties for the SwiperJS Keyboard Control module.
Name | Type | Description |
---|---|---|
| boolean | Whether the mousewheel control is enabled. |
Methods
Find below available Methods for the SwiperJS Mousewheel Control module.
Method | Description |
---|---|
| Disable mousewheel control. |
| Enable mousewheel control. |
Events
Find below available Events for the SwiperJS Mousewheel Control module.
scroll
Event fired on mousewheel scroll.
Usage |
---|
|
Navigation
In SwiperJS, the Navigation module provides a way to control the slider’s movement using dedicated "next" and "previous" buttons.
- Customizable Buttons
-
You can use your own HTML elements (like buttons or icons) as navigation controls.
- Flexibility
-
The module offers options to customize the appearance and behavior of the navigation buttons.
Parameters
Find all parameters available for the Navigation module.
Name | Type | Default | Description |
---|---|---|---|
| string | swiper-button-disabled | CSS class name added to navigation button when it becomes disabled. |
| boolean | no default | Boolean property to use with breakpoints to enable/disable navigation on certain breakpoints |
| string | swiper-button-hidden | CSS class name added to navigation button when it becomes hidden. |
| boolean |
| Toggle navigation button visibility after click on Slider’s container. |
| string | swiper-button-lock | CSS class name added to navigation button when it is disabled. |
| string | swiper-navigation-disabled | CSS class name added on swiper container when navigation is disabled by breakpoint |
| any | null | String with CSS selector or HTML element of the element that will work like next button after click on it. |
| any | null | String with CSS selector or HTML element of the element that will work like prev button after click on it. |
Properties
Find below available Properties for the SwiperJS Navigation module.
Name | Description | Example |
---|---|
| HTMLElement of next navigation button. |
| HTMLElement of previous navigation button |
Methods
Find below available Methods for the SwiperJS Navigation module.
Name | Description |
---|---|
| Destroy navigation. |
| Initialize navigation. |
| Update navigation buttons state (enabled/disabled). |
Events
Find below available Events for the SwiperJS Navigation module.
navigationHide
Event will be fired on navigation hide
Usage |
---|
|
navigationNext
Event will be fired on click the navigation next button.
Usage |
---|
|
navigationPrev
Event will be fired on click the navigation prev button.
Usage |
---|
|
navigationShow
Event will be fired on navigation show.
Usage |
---|
|
CSS Properties
Find below available CSS Properties for the SwiperJS Navigation module.
{
--swiper-navigation-size: 44px;
--swiper-navigation-top-offset: 50%;
--swiper-navigation-sides-offset: 10px;
--swiper-navigation-color: var(--swiper-theme-color);
}
Pagination
The Pagination module in SwiperJS is a powerful tool that allows you to add visual indicators (like buttons) to a SwiperJS slide. The navigation elements make it clear to users how many slides there are and which slide they are currently viewing. Here’s a breakdown of its key functionalities:
- Active State
-
The indicator corresponding to the currently active slide is visually highlighted to provide immediate feedback to the user.
- User Interaction
-
In many cases, the pagination indicators are clickable. Clicking on an indicator will directly navigate the slider to the corresponding slide.
- Visual Indicators
-
The module generates a set of visual indicators (often small dots or numbers) that represent each slide in your slider.
Parameters
Find all parameters available for the Pagination module.
Name | Type | Default | Description | Example |
---|---|---|---|
| string | swiper-pagination-bullet-active | CSS class name of the active pagination bullet. |
| string | swiper-pagination-bullet | CSS class name of the pagination bullet. |
| string | span | Defines which HTML tag will be used to represent single pagination bullet. Only for pagination type of bullets . |
| boolean |
| If |
| string | swiper-pagination-clickable | CSS class name set to pagination if its clickable. |
| string | swiper-pagination-current | CSS class name of the element with currently active index in fraction pagination. |
| boolean |
| Good to enable if you use bullets pagination with a lot of slides. So it will keep only few bullets visible at the same time. |
| number | 1 | The number of main bullets visible when |
| any | null | String with CSS selector or HTML element of the container with pagination. |
| boolean | no default | Boolean property to use with breakpoints to enable/disable pagination on certain breakpoints. |
| function(number) | no default | Format fraction pagination current number. Function receives current number, and you need to return formatted value. |
| function(number) | no default | Format fraction pagination total number. Function receives total number, and you need to return formatted value. |
| string | swiper-pagination-hidden | CSS class name of pagination when it becomes inactive. |
| boolean |
| Toggle (hide/show) pagination container visibility after click on slider’s container. |
| string | swiper-pagination-horizontal | CSS class name set to pagination in horizontal Swiper. |
| string | swiper-pagination-lock | CSS class name set to pagination when it is disabled. |
| string | swiper-pagination- | The beginning of the modifier CSS class name that will be added to pagination depending on parameters. |
| string | swiper-pagination-disabled | CSS class name added on swiper container and pagination element when pagination is disabled by breakpoint. |
| string | swiper-pagination-progressbar-fill | CSS class name of pagination progressbar fill element. |
| boolean |
| Makes pagination progressbar opposite to Swiper’s |
| string | swiper-pagination-progressbar-opposite | CSS class name of pagination progressbar opposite |
| function(args) | no default | This parameter allows totally customize pagination bullets, you need to pass here a function that accepts
|
| function(args) | no default | This parameter is required for custom pagination type where you have to specify how it should be rendered.
|
| function(args) | no default | This parameter allows to customize fraction pagination html. Only for fraction pagination type.
|
| function(args) | no default | This parameter allows to customize "progress" pagination. Only for progress pagination type
|
| string | swiper-pagination-total | CSS class name of the element with total number of snaps in fraction pagination. |
| string | bullets | String with type of pagination. |
| string | swiper-pagination-vertical | CSS class name set to pagination in vertical Swiper. |
Properties
Find below available Properties for the SwiperJS Pagination module.
Property | Description | Example |
---|---|
| Array of pagination bullets HTML elements. To get specific slide HTMLElement use |
| HTMLElement of pagination container element. |
Methods
Find below available Methods for the SwiperJS Pagination module.
Method | Description |
---|---|
| Destroy pagination. |
| Initialize pagination. |
| Render pagination layout. |
| Update pagination state of enabled | disabled | active. |
Events
Find below available Events for the SwiperJS Pagination module.
paginationHide
Event will be fired on pagination hide.
Usage |
---|
|
paginationRender
Event will be fired after pagination rendered.
Usage |
---|
|
paginationShow
Event will be fired when pagination is shown.
Receives paginationEl event as an argument. |
Usage |
---|
|
paginationUpdate
Event will be fired when pagination updated
Receives paginationEl event as an argument. |
Usage |
---|
|
CSS Properties
Find below available CSS Properties for the SwiperJS Pagination module.
{
--swiper-pagination-color: var(--swiper-theme-color);
--swiper-pagination-left: auto;
--swiper-pagination-right: 8px;
--swiper-pagination-bottom: 8px;
--swiper-pagination-top: auto;
--swiper-pagination-fraction-color: inherit;
--swiper-pagination-progressbar-bg-color: rgba(0, 0, 0, 0.25);
--swiper-pagination-progressbar-size: 4px;
--swiper-pagination-bullet-size: 8px;
--swiper-pagination-bullet-width: 8px;
--swiper-pagination-bullet-height: 8px;
--swiper-pagination-bullet-inactive-color: #000;
--swiper-pagination-bullet-inactive-opacity: 0.2;
--swiper-pagination-bullet-opacity: 1;
--swiper-pagination-bullet-horizontal-gap: 4px;
--swiper-pagination-bullet-vertical-gap: 6px;
}
Parallax
The SwiperJS parallax module supports parallax transition effects for swiper/slides nested elements. There are two types of parallax elements supported:
-
Direct child elements of
swiper
. Parallax effect for such elements will depend on total slider progress. Useful for parallax backgrounds. -
Slides child elements. Parallax effect for such elements will depend on slide progress
To enable parallax effects you need to init SwiperJS instance with passed parallax: true
parameter and add one of the following (or mix) attributes to required elements:
-
data-swiper-parallax
, enable transform-translate parallax transition. This attribute may accept:-
number
, value in px (as for title, subtitle in example above) to move element depending on progress. In this case such element will be moved on ± this value in px depending on slide position (next or previous) -
percentage
, (as for "parallax-bg") to move element depending on progress and on its size. In this case such element will be moved on ± this percentage of its size (width in horizontal direction, and height in vertical direction) depending on slide position (next or previous). So if element has 400px width and you specified data-swiper-parallax="50%" then it will be moved on ± 200px
-
-
data-swiper-parallax-x
, same but for x-axis direction -
data-swiper-parallax-y
, same but for y-axis direction -
data-swiper-parallax-scale
, scale ratio of the parallax element when it is in "inactive" (not on active slide) state -
data-swiper-parallax-opacity
, opacity of the parallax element when it is in "inactive" (not on active slide) state -
data-swiper-parallax-duration
, custom transition duration for parallax elements
<div class="swiper">
<!-- Parallax background element -->
<div
class="parallax-bg"
style="background-image:url(path/to/image.jpg)"
data-swiper-parallax="-23%"
></div>
<div class="swiper-wrapper">
<div class="swiper-slide">
<!-- Each slide has parallax title -->
<div class="title" data-swiper-parallax="-100">Slide 1</div>
<!-- Parallax subtitle -->
<div class="subtitle" data-swiper-parallax="-200">Subtitle</div>
<!-- And parallax text with custom transition duration -->
<div
class="text"
data-swiper-parallax="-300"
data-swiper-parallax-duration="600"
>
<p>Lorem ipsum dolor sit amet, ...</p>
</div>
<!-- Opacity parallax -->
<div data-swiper-parallax-opacity="0.5">I will change opacity</div>
<!-- Scale parallax -->
<div data-swiper-parallax-scale="0.15">I will change scale</div>
</div>
...
</div>
</div>
Parameters
Find all parameters available for the Parallax module.
Name | Type | Default | Description |
---|---|---|---|
| boolean |
| Enable, if you want to use parallaxed elements inside of slider. |
Scrollbar
The Scrollbar module in SwiperJS is a powerful tool that enhances user interaction and provides visual feedback within your slider. Here’s a breakdown of its key functionalities:
- Visual Indicator
-
The module renders a visual scrollbar that dynamically reflects the slider’s current position. This provides users with a clear understanding of where they are within the overall content.
- Draggable Interaction
-
The scrollbar can be made draggable, allowing users to directly control the slider’s position by moving the scrollbar handle. This offers an alternative navigation method to swiping or clicking.
- Customization
-
You can extensively customize the appearance and behavior of the scrollbar to match your project’s design. This includes options for size, color, position, and more.
Parameters
Find all parameters available for the Scrollbar module.
Name | Type | Default | Description |
---|---|---|---|
| string | swiper-scrollbar-drag | Scrollbar draggable element CSS class. |
| number | auto | auto | Size of scrollbar draggable element in px. |
| boolean |
| Set to |
| any | null | String with CSS selector or HTML element of the container with scrollbar. |
| boolean | no default | Boolean property to use with breakpoints to enable | disable scrollbar on certain breakpoints. |
| boolean |
| Hide scrollbar automatically after user interaction. |
| string | swiper-scrollbar-horizontal | CSS class name set to scrollbar in horizontal Swiper. |
| string | swiper-scrollbar-lock | Scrollbar element additional CSS class when it is disabled. |
| string | swiper-scrollbar-disabled | CSS class name added on swiper container and scrollbar element when scrollbar is disabled by breakpoint. |
| boolean |
| Set to |
| string | swiper-scrollbar-vertical | CSS class name set to scrollbar in vertical Swiper. |
Properties
Find below available Properties for the SwiperJS Scrollbar module.
Property | Description |
---|---|
| HTML Element of Scrollbar draggable handler element. |
| HTML Element of Scrollbar container element. |
Methods
Find below available Methods for the SwiperJS Scrollbar module.
Name | Description |
---|---|
| Destroy scrollbar. |
| Initialize scrollbar. |
| Updates scrollbar translate. |
| Updates scrollbar track and handler sizes. |
Events
scrollbarDragEnd
Event fired on draggable scrollbar drag end.
Receives scrollbar event as an argument. |
Usage |
---|
|
scrollbarDragMove
Event will be fired on draggable scrollbar drag move.
Receives scrollbar event as an argument. |
Usage |
---|
|
scrollbarDragStart
Event will be fired on draggable scrollbar drag start.
Receives scrollbar event as an argument. |
Usage |
---|
|
CSS Properties
{
--swiper-scrollbar-border-radius: 10px;
--swiper-scrollbar-top: auto;
--swiper-scrollbar-bottom: 4px;
--swiper-scrollbar-left: auto;
--swiper-scrollbar-right: 4px;
--swiper-scrollbar-sides-offset: 1%;
--swiper-scrollbar-bg-color: rgba(0, 0, 0, 0.1);
--swiper-scrollbar-drag-bg-color: rgba(0, 0, 0, 0.5);
--swiper-scrollbar-size: 4px;
}
Thumbs
In SwiperJS, the Thumbs module enables to create a thumbnail navigation (slave) for (master) sliders.
In addition to the SwiperJS Controller module the API comes with the Thumbs module that is designed to work with a additional (slave) thumbs swiper for a more correct way for syncing two swipers.
Parameters
Find all parameters available for the Thumbs module.
Name | Type | Default | Description |
---|---|---|---|
| number | 0 | Allows to set on which thumbs active slide from edge it should automatically move scroll thumbs. For example, if set to 1 and last visible thumb will be activated (1 from edge) it will auto scroll thumbs. |
| boolean |
| When enabled multiple thumbnail slides may get activated. |
| string | swiper-slide-thumb-active | Additional class that will be added to activated thumbs swiper slide. |
| any | null | SwiperJS instance of swiper used as thumbs or object with SwiperJS API parameters to initialize thumbs swiper. |
| string | swiper-thumbs | Additional class that will be added to thumbs swiper |
Properties
Find below available Properties for the SwiperJS Thumbs module.
Name | Type | Description |
---|---|---|
| any | SwiperJS instance of thumbs swiper. |
Methods
Find below available Methods for the SwiperJS Thumbs module.
init
Initialize thumbs.
Usage |
---|
|
update
Update thumbs.
Usage |
---|
|
Virtual Slides
Virtual Slides module allows to keep just required amount of slides in DOM. It is very useful in terms in performance and memory issues if you have a lot of slides, especially slides with heavyweight DOM tree or images.
Virtual Slides doesn’t work with Grid module and if parameter |
Parameters
Find all parameters available for the Virtual Slides module.
Name | Type | Default | Description |
---|---|---|---|
| number | 0 | Increases amount of pre-rendered slides after active slide. |
| number | 0 | Increases amount of pre-rendered slides before active slide. |
| boolean |
| Enables DOM cache of rendering slides html elements. Once rendered, they will be saved to cache and reused from it. |
| boolean |
| Whether the virtual slides are enabled. |
| function(data) | no default | Function for external rendering (e.g. using some other library to handle DOM manipulations and state like React.js or Vue.js). As an argument it accepts
|
| boolean |
| When enabled (by default) it will update swiper layout right after renderExternal called. Useful to disable and update swiper manually when used with render libraries that renders asynchronously |
| function(slide, index) | no default | Function to render slide. As an argument it accepts current slide item for |
| Text[] | [] | Array with slides. |
Name | Type | Description |
---|---|---|
| object | Object with cached slides HTML elements. |
| number | Index of first rendered slide. |
| Text[] | Array with slide items passed by |
| number | Index of last rendered slide. |
Methods
Find below available Methods for the SwiperJS Virtual Slides module.
Name | Description | ||
---|---|---|---|
| Append slide. Slides defined by
| ||
| Prepend slide. Slides defined by
| ||
| Remove all slides.
| ||
| Remove specific slide or slides. Index defined by
| ||
| Update virtual slides state. |
DOM
Since version 9, SwiperJS virtual slides can work with slides originally rendered in DOM. On initialize it will remove them from DOM, cache and then re-use the ones which are required:
<div class="swiper">
<div class="swiper-wrapper">
<div class="swiper-slide">Slide 1</div>
<div class="swiper-slide">Slide 2</div>
...
<div class="swiper-slide">Slide 100</div>
</div>
</div>
<script>
const swiper = new Swiper('#swiper_id', {
virtual: {
enabled: true
}
});
</script>
Zoom
SwiperJS supports a Zoom functionality on images (similar to what you see on iOS when browsing single photo) where you can zoom-in image by pinch gesture and or by zoom-in/zoom-out by double tap on it. In this case, a additional layout is required:
<div class="swiper">
<div class="swiper-wrapper">
<div class="swiper-slide">
<div class="swiper-zoom-container">
<img src="path/to/image1.jpg" />
</div>
</div>
<div class="swiper-slide">
<div class="swiper-zoom-container">
<img src="path/to/image2.jpg" />
</div>
</div>
<div class="swiper-slide">Plain slide with text</div>
<div class="swiper-slide">
<!-- Override maxRatio parameter -->
<div class="swiper-zoom-container" data-swiper-zoom="5">
<img src="path/to/image1.jpg" />
</div>
</div>
</div>
</div>
All zoomable images should be wrapped with the div with swiper-zoom-container class. By default it expects to zoom one of the img
, picture
or canvas
element. If you want to make zoom on some other custom element, then just add swiper-zoom-target class to this element.
<div class="swiper">
<div class="swiper-wrapper">
<div class="swiper-slide">
<div class="swiper-zoom-container">
<!-- custom zoomable element -->
<div
class="swiper-zoom-target"
style="background-image: url(...)"
></div>
</div>
</div>
</div>
</div>
You can override maxRatio
parameter for specific slides by using data-swiper-zoom
attribute on zoom container.
Parameters
Find all parameters available for the Zoom module.
Name | Type | Default | Description |
---|---|---|---|
| string | swiper-zoom-container | CSS class name of zoom container. |
| boolean |
| When set to true, the image will not be scaled past 100% of its original size. |
| number | 3 | Maximum image zoom multiplier. |
| number | 1 | Minimal image zoom multiplier. |
| boolean |
| When set to true, a zoomed in image will automatically pan while moving the mouse over the image. |
| boolean |
| Enable/disable zoom-in by slide’s double tap. |
| string | swiper-slide-zoomed | CSS class name of zoomed in container. |
Properties
Find below available Properties for the SwiperJS Zoom module.
Name | Type | Description |
---|---|---|
| boolean | Whether the zoom module is enabled. |
| number | Current image scale ratio. |
Methods
Find below available Methods for the SwiperJS Zoom module.
Name | Description |
---|---|
| Disable the Zoom module. |
| Enable the Zoom module. |
| Zoom in the image of the currently active slide. Optionally accepts custom zoom ratio. |
| Zoom out the image of the currently active slide. |
| Toggle image zoom of the currently active slide. |
Events
The module allows you to zoom in and out of images within a slider. Zoom Events likely refers to custom events you might create or utilize within a SwiperJS implementation to:
-
Trigger actions when zooming begins, ends, or changes.
-
Coordinate with other parts of your application based on zoom levels.
-
Enhance user interactions with dynamic effects or UI updates.
zoomChange
Event fired on zoom change.
Receives evants scale, imageEl, slideEl as an argument. |
Usage |
---|
|
Methods
Find method settings also with the Swiper Documentation.
Change the Swiper instance variable swiper used in column Synopsis to your setup. |
attachEvents
Re-Attach all event listeners configured for an instance.
Synopsis | Description | Parameters |
---|---|
| Attach all event listeners again. |
changeDirection
Change the slider orientation from horizontal to vertical or back.
Synopsis | Description | Parameters |
---|---|
| Change the slider orientation from horizontal to vertical and back.
|
changeLanguageDirection
Changes slider language direction.
Synopsis | Description | Parameters |
---|---|
| Changes slider language direction.
|
destroy
Destroy a slider instance and detach all event listeners.
Synopsis | Description | Parameters |
---|---|
| Destroy a slider instance and detach all event listeners.
|
detachEvents
Detach all event listeners.
Synopsis | Description | Parameters |
---|---|
| Detach all event listeners. |
disable
Disable Swiper (if it was enabled). When Swiper is disabled, it will hide all navigation elements and won’t respond to any events and interactions.
Synopsis | Description | Parameters |
---|---|
| Disable Swiper (if it was enabled). When Swiper is disabled, it will hide all navigation elements and won’t respond to any events and interactions. |
emit
Fire event on instance.
Synopsis | Description | Parameters |
---|---|
| Fire event on instance. |
enable
Enable a swiper instance (if it was disabled).
Synopsis | Description | Parameters |
---|---|
| Enable a swiper instance (if it was disabled). |
extendDefaults
Extend a swiper instance by (global) swiper options (properties). See section [Common options] for common, frequently used options.
Synopsis | Description | Parameters |
---|---|
| Extend a swiper instance by (global) swiper options (properties). See section [Common options] for common, frequently used options. |
getTranslate
Get current values of swiper wrapper CSS3 transform translate settings.
Synopsis | Description | Parameters |
---|---|
| Get current values of swiper wrapper CSS3 transform translate settings. |
init
Initialize a slider on its HTML element el
.
Synopsis | Description | Parameters |
---|---|
| Initialize a slider on its HTML element |
maxTranslate
Get current maximal CSS3 transform translate value.
Synopsis | Description | Parameters |
---|---|
| Get current minimal CSS3 transform translate value. |
minTranslate
Get current maximal CSS3 transform translate value.
Synopsis | Description | Parameters |
---|---|
| Get current minimal CSS3 transform translate value. |
off
Remove a event handler.
Synopsis | Description | Parameters |
---|---|
| Remove a event handler. |
offAny
Remove a event listener that will be fired on all events.
Synopsis | Description | Parameters |
---|---|
| Remove a event listener that will be fired on all events. |
on
Add a event handler.
Synopsis | Description | Parameters |
---|---|
| Add a event handler. |
onAny
Add a event listener that will be fired on all events.
Synopsis | Description | Parameters |
---|---|
| ReAddmove a event listener that will be fired on all events. |
once
Add a event handler that is run only once. The event handler will be removed after it was fired.
Synopsis | Description | Parameters |
---|---|
| Add a event handler that is run only once. The event handler will be removed after it was fired. |
setGrabCursor
Enable|Set a grab cursor on the swiper instance.
Synopsis | Description | Parameters |
---|---|
| Enable | Set a grab cursor on the swiper instance. |
setProgress
Set Swiper translate progress (from 0 to 1). Where 0 its initial position (offset) on first slide, and 1 its maximum position (offset) on last slide.
Synopsis | Description | Parameters |
---|---|
| Set Swiper translate progress (from 0 to 1). Where 0 its initial position (offset) on first slide, and 1 its maximum position (offset) on last slide.
|
setTranslate
Set custom values for CSS3 transform translate settings of the swiper wrapper.
Synopsis | Description | Parameters |
---|---|
| Set custom values for CSS3 transform translate settings of the swiper wrapper. |
slideNext
Run transition to next slide.
Synopsis | Description | Parameters |
---|---|
| Run transition to next slide.
|
slidePrev
Run transition to previous slide.
Synopsis | Description | Parameters |
---|---|
| Run transition to previous slide.
|
slideReset
Reset swiper position to currently active slide for the duration equal to speed
parameter.
Synopsis | Description | Parameters |
---|---|
| Reset swiper position to currently active slide for the duration equal to
|
slideTo
Run transition to the slide with index number equal to the index
parameter for the duration equal to speed
parameter.
Synopsis | Description | Parameters |
---|---|
| Run transition to the slide with index number equal to the
|
slideToClosest
Reset swiper position to closest slide/snap point for the duration equal to speed
parameter.
Synopsis | Description | Parameters |
---|---|
| Reset swiper position to closest slide/snap point for the duration equal to
|
slideToLoop
Does the same as method slideTo() but in case when used with enabled loop. So this method will slide to slides with realIndex matching to passed index.
Synopsis | Description | Parameters |
---|---|
| Does the same as method slideTo() but in case when used with enabled loop. So this method will slide to slides with realIndex matching to passed index.
|
slidesPerViewDynamic
Get dynamically calculated amount of slides per view. Only useful when property slidesPerView
set to auto
.
Synopsis | Description | Parameters | ||
---|---|---|---|
| Get dynamically calculated amount of slides per view.
|
translateTo
Animate custom CSS3 transform' translate value for swiper wrapper.
Synopsis | Description | Parameters |
---|---|
| Animate custom CSS3 transform' translate value for swiper wrapper.
|
role="mt-4"]
unsetGrabCursor
Disable | Unset a grab cursor on the swiper instance.
Synopsis | Description | Parameters |
---|---|
| Disable|Unset a grab cursor on the swiper instance. |
update
Should called after add/remove slides manually, or after hide/show a slider, or any custom DOM modifications done with Swiper.
Synopsis | Description | Parameters |
---|---|
| Should called after add/remove slides manually, or after hide/show a slider, or any custom DOM modifications done with a swiper. |
updateAutoHeight
Force swiper to update its height (when autoHeight
is enabled) for the duration equal to speed
parameter.
Synopsis | Description | Parameters |
---|---|
| Force swiper to update its height (when
|
updateProgress
Recalculate swiper progress.
Synopsis | Description | Parameters |
---|---|
| Recalculate swiper progress. |
updateSize
Recalculate size of swiper container.
Synopsis | Description | Parameters |
---|---|
| Recalculate size of swiper container. |
updateSlides
Recalculate number of slides and their offsets. Useful after add/remove slides.
Synopsis | Description | Parameters |
---|---|
| Recalculate number of slides and their offsets. Useful after add/remove slides. |
updateSlidesClasses
Update active/prev/next classes on slides and bullets.
Synopsis | Description | Parameters |
---|---|
| Update active/prev/next classes on slides and bullets. |
updateSlidesClasses
Installs Swiper modules on a instance at runtime.
Synopsis | Description | Parameters |
---|---|
| Installs Swiper modules on a instance at runtime. |
Events A - R
The Swiper API comes with a large number of predefined event listeners you can assign to an (swiper) instance. Find available event listeners also with the Swiper Documentation.
Assignment
Events can be assigned in two ways.
On swiper initialization
Fire event on swiper initialization.
const swiper = new Swiper('#swiper_id', {
// ...
on: {
init: function function (swiper) {
console.log('swiper initialized');
}
}
});
After swiper initialization
Fire event after swiper initialization.
const swiper = new Swiper('#swiper_id', {
// ...
});
swiper.on('slideChange', function (swiper) {
console.log('slide changed');
});
The this keyword within a event handler points always to the swiper instance. |
Listeners
Available predefined event listeners.
activeIndexChange
Event fired on active index change.
Usage |
---|
|
afterInit
Event fired right after swipers initialization.
Usage |
---|
|
beforeDestroy
Event fired right before swiper instance is destroyed.
Usage |
---|
|
beforeInit
Event fired right before swiper initialization.
Usage |
---|
|
afterDestroy
Event fired right after swiper instance is destroyed.
Usage |
---|
|
beforeLoopFix
Event fired right before loop fix.
Usage |
---|
|
beforeResize
Event fired before resize handler.
Usage |
---|
|
beforeSlideChangeStart
Event fired before slide change transition start.
Usage |
---|
|
beforeTransitionStart
Event fired before transition starts.
Usage |
---|
|
breakpoint
Event fired on breakpoint change
Usage |
---|
|
changeDirection
Event fired on direction change.
Usage |
---|
|
click
Event fired when user click/tap on Swiper.
Receives pointerup event as an argument. |
Usage |
---|
|
destroy
Event fired after swiper is destroyed.
Usage |
---|
|
doubleClick
Event fired when user double click/tap on Swiper.
Usage |
---|
|
doubleTap
Event fired when user double tap on the Swipers container.
Receives pointerup event as an argument. |
Usage |
---|
|
fromEdge
Event fired when Swiper goes from beginning or end position.
Usage |
---|
|
init
Fired after Swiper initialization.
The
Otherwise use the event as an initialization parameter on instance setup (new) as shown below. |
Usage |
---|
|
lock
Event fired when swiper is locked (if watchOverflow
is enabled).
Usage |
---|
|
loopFix
Event fired after loop fix.
Usage |
---|
|
momentumBounce
Event fired on momentum bounce.
Usage |
---|
|
observerUpdate
Event fired if observer is enabled and a DOM mutations is detected.
Usage |
---|
|
orientationchange
Event fired on orientation change (e.g. landscape → portrait).
Usage |
---|
|
progress
Event fired when Swiper progress has been changed.
Receives progress event as an argument. |
Usage |
---|
|
reachBeginning
Event fired when Swiper reach its beginning (initial position).
Usage |
---|
|
reachEnd
Event fired when Swiper reach last slide.
Usage |
---|
|
realIndexChange
Event fired on real index change.
Usage |
---|
|
resize
Event fired on window resize and before on s swiper onresize manipulation.
Usage |
---|
|
Events S - Z
The Swiper API comes with a large number of predefined event listeners you can assign to an (swiper) instance. Find available event listeners also with the Swiper Documentation.
setTransition
Event fired everytime when swiper starts animation.
Receives transition duration value (in ms) as an argument. |
Usage |
---|
|
setTranslate
Set custom CSS3 transform translate value for the swiper wrapper.
Receives current translate value as as argument. |
Usage |
---|
|
slideChange
Event fired when active slide has been changed.
Usage |
---|
|
slideChangeTransitionEnd
Event fired after animation to other slide (next or previous).
Usage |
---|
|
slideChangeTransitionStart
Event fired in the beginning of animation to other slide (next or previous).
Usage |
---|
|
slideNextTransitionEnd
Same as slideChangeTransitionEnd but only for forward direction.
Usage |
---|
|
slideNextTransitionStart
Same as slideChangeTransitionStart but only for forward direction.
Usage |
---|
|
slidePrevTransitionEnd
Same as slideChangeTransitionEnd but only for backward direction.
Usage |
---|
|
slidePrevTransitionStart
Same as slideChangeTransitionStart but only for backward direction.
Usage |
---|
|
slideResetTransitionEnd
Event fired in the end of animation of resetting slide to current one.
Usage |
---|
|
slideResetTransitionStart
Event fired in the beginning of animation of resetting slide to current one.
Usage |
---|
|
sliderFirstMove
Event fired when user touch and move finger over Swiper and move it.
Receives pointermove event as an argument. |
Usage |
---|
|
sliderMove
Event fired when user touch and move finger over Swiper and move it.
Receives pointermove event as an argument. |
Usage |
---|
|
slidesGridLengthChange
Event fired when slides grid has been changed.
Usage |
---|
|
slidesLengthChange
Event fired when number of slides has been changed.
Usage |
---|
|
slidesUpdated
Event fired after slides and their sizes are calculated and updated.
Usage |
---|
|
snapGridLengthChange
Event fired when snap grid has been changed.
Usage |
---|
|
snapIndexChange
Event fired when snap index has been changed.
Usage |
---|
|
tap
Event fired when user click/tap on Swiper.
Receives pointerup event as an argument. |
Usage |
---|
|
toEdge
Event fired when Swiper goes to beginning or end position.
Usage |
---|
|
touchEnd
Event fired after user releases the swiper.
Receives pointerup event as an argument. |
Usage |
---|
|
touchMove
Event fired when user touch and move finger over the swiper.
Receives pointermove event as an argument. |
Usage |
---|
|
touchMoveOpposite
Event fired when user touch and move finger over Swiper in opposite to the direction parameter.
Receives pointermove event as an argument. |
Usage |
---|
|
touchStart
Event fired when user touches the swiper.
Receives pointerdown event as an argument. |
Usage |
---|
|
transitionEnd
Event fired after a transition.
Usage |
---|
|
transitionStart
Event fired in the beginning of a transition.
Usage |
---|
|
unlock
Event fired when swiper is unlocked (if parameter watchOverflow
is enabled).
Usage |
---|
|
update
Event fired after update() call is finished.
Usage |
---|
|