Top Related Projects
the last carousel you'll ever need
A dependency-free JavaScript ES6 slider and carousel. It’s lightweight, flexible and fast. Designed to slide. No less, no more
Splide is a lightweight, flexible and accessible slider/carousel written in TypeScript. No dependencies, no Lighthouse errors.
A lightweight carousel library with fluid motion and great swipe precision.
Quick Overview
Swiper is a modern, mobile-friendly JavaScript slider library with hardware-accelerated transitions and amazing native behavior. It's designed to be used in mobile websites, mobile web apps, and mobile native/hybrid apps. Swiper is free and open-source.
Pros
- Highly customizable with numerous options and API methods
- Smooth, hardware-accelerated transitions for optimal performance
- Responsive and touch-friendly, works well on both mobile and desktop devices
- Active development and community support
Cons
- Can be overkill for simple slider needs
- Learning curve for advanced customizations
- Potential performance issues if not optimized properly
- Dependency on external library may increase overall project size
Code Examples
- Basic Swiper initialization:
const swiper = new Swiper('.swiper', {
slidesPerView: 3,
spaceBetween: 30,
pagination: {
el: '.swiper-pagination',
clickable: true,
},
});
- Swiper with navigation buttons:
const swiper = new Swiper('.swiper', {
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
});
- Responsive breakpoints:
const swiper = new Swiper('.swiper', {
slidesPerView: 1,
spaceBetween: 10,
breakpoints: {
640: {
slidesPerView: 2,
spaceBetween: 20,
},
768: {
slidesPerView: 4,
spaceBetween: 40,
},
},
});
Getting Started
-
Install Swiper via npm:
npm install swiper
-
Import Swiper and its styles in your JavaScript file:
import Swiper from 'swiper'; import 'swiper/css';
-
Add Swiper HTML layout to your page:
<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 3</div> </div> <div class="swiper-pagination"></div> </div>
-
Initialize Swiper:
const swiper = new Swiper('.swiper', { pagination: { el: '.swiper-pagination', }, });
Competitor Comparisons
the last carousel you'll ever need
Pros of Slick
- Lightweight and simple to use, with minimal setup required
- Extensive browser support, including older versions of Internet Explorer
- Responsive design with built-in breakpoints for different screen sizes
Cons of Slick
- Less feature-rich compared to Swiper, with fewer advanced options
- Not as actively maintained, with fewer updates and bug fixes
- Limited touch support and mobile optimization compared to Swiper
Code Comparison
Slick initialization:
$('.slider').slick({
slidesToShow: 3,
slidesToScroll: 1,
autoplay: true,
autoplaySpeed: 2000,
});
Swiper initialization:
const swiper = new Swiper('.swiper-container', {
slidesPerView: 3,
spaceBetween: 30,
autoplay: {
delay: 2000,
},
});
Both libraries offer similar basic functionality, but Swiper provides more advanced options and better performance for complex use cases. Slick is easier to set up and use for simple slider needs, while Swiper offers more flexibility and features for advanced implementations.
A dependency-free JavaScript ES6 slider and carousel. It’s lightweight, flexible and fast. Designed to slide. No less, no more
Pros of Glide
- Lightweight: Glide has a smaller file size, making it more suitable for projects where minimizing load times is crucial.
- Simpler API: Glide offers a more straightforward and easier-to-use API, which can be beneficial for developers who prefer simplicity.
- No dependencies: Glide is a standalone library without external dependencies, potentially reducing conflicts in your project.
Cons of Glide
- Fewer features: Glide has a more limited set of features compared to Swiper's extensive functionality.
- Less active development: Glide has fewer updates and a smaller community, which may result in slower bug fixes and feature additions.
- Limited browser support: Glide may not work as well on older browsers compared to Swiper's broader compatibility.
Code Comparison
Glide initialization:
new Glide('.glide').mount()
Swiper initialization:
new Swiper('.swiper-container', {
direction: 'horizontal',
loop: true
})
Both libraries offer simple initialization, but Swiper provides more configuration options out of the box. Glide's approach is more minimalistic, while Swiper offers greater flexibility for complex use cases.
Splide is a lightweight, flexible and accessible slider/carousel written in TypeScript. No dependencies, no Lighthouse errors.
Pros of Splide
- Lighter weight and faster performance
- No dependencies, pure JavaScript
- More flexible and customizable API
Cons of Splide
- Smaller community and ecosystem compared to Swiper
- Fewer built-in features and modules
Code Comparison
Splide initialization:
new Splide('.splide', {
type: 'loop',
perPage: 3,
autoplay: true
}).mount();
Swiper initialization:
new Swiper('.swiper', {
loop: true,
slidesPerView: 3,
autoplay: {
delay: 3000,
},
});
Both libraries offer similar basic functionality, but Splide's API is generally more concise. Swiper provides more options out of the box, while Splide focuses on core functionality and leaves advanced features to extensions.
Splide's smaller file size and lack of dependencies make it a good choice for projects prioritizing performance and minimalism. Swiper, with its larger community and extensive feature set, may be preferable for complex projects requiring advanced functionality or widespread support.
Ultimately, the choice between Splide and Swiper depends on specific project requirements, desired features, and performance considerations.
A lightweight carousel library with fluid motion and great swipe precision.
Pros of Embla Carousel
- Lightweight and performant, with a smaller bundle size
- More flexible and customizable, allowing for advanced layouts
- Better touch and mouse drag support, especially for mobile devices
Cons of Embla Carousel
- Less extensive documentation compared to Swiper
- Fewer built-in features and plugins out of the box
- Smaller community and ecosystem around the project
Code Comparison
Embla Carousel:
import EmblaCarousel from 'embla-carousel'
const embla = EmblaCarousel(document.querySelector('.embla'), {
loop: true,
align: 'center'
})
Swiper:
import Swiper from 'swiper'
const swiper = new Swiper('.swiper-container', {
loop: true,
centeredSlides: true
})
Both libraries offer similar basic setup, but Embla Carousel's API is more focused on providing core functionality, while Swiper offers a wider range of options and features by default. Embla Carousel's approach allows for more granular control over the carousel behavior, but may require more custom code for advanced features. Swiper, on the other hand, provides many built-in options that can be easily configured without additional coding.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Get Started | Documentation | Demos
Swiper
Swiper - is the free and most modern mobile touch slider with hardware accelerated transitions and amazing native behavior. It is intended to be used in mobile websites, mobile web apps, and mobile native/hybrid apps.
Swiper is not compatible with all platforms, it is a modern touch slider which is focused only on modern apps/platforms to bring the best experience and simplicity.
Sponsors
Features
- Tree-shakeable: Only modules you use will be imported into your app's bundle.
- Mobile-friendly: It is intended to be used in mobile websites, mobile web apps, and mobile native/hybrid apps.
- Library Agnostic: Swiper doesn't require any JavaScript libraries like jQuery, which makes Swiper much smaller and faster. It can be safely used with libraries such as jQuery, Zepto, jQuery Mobile, etc.
- 1:1 Touch movement: By default, Swiper provides 1:1 touch movement interaction, but this ratio can be configured through Swiper settings.
- Mutation Observer: Swiper has an option to enable Mutation Observer, with this feature Swiper will be automatically reinitialized and recalculate all required parameters if you make dynamic changes to the DOM, or in Swiper styles itself.
- Rich API: Swiper comes with a very rich API. It allows creating your own pagination, navigation buttons, parallax effects and many more.
- RTL: Swiper is the only slider that provides 100% RTL support with correct layout.
- Multi Row Slides Layout: Swiper allows a multiple row slides layout, with a few slides per column.
- Transition Effects: Fade, Flip, 3D Cube, 3D Coverflow.
- Two-way Control: Swiper may be used as controller for any number of other Swipers, and even be controlled at the same time.
- Full Navigation Control: Swiper comes with all required built-in navigation elements, such as Pagination, Navigation arrows and Scrollbar.
- Flexbox Layout: Swiper uses modern flexbox layout for slides layout, which solves a lot of problems and time with size caclulations. Such layout also allows configuring the Slides grid using pure CSS.
- Most Flexible Slides Layout Grid: Swiper has a lot of parameters on initialization to make it as flexible as possible. You can control slides per view, per column, per group, space between slides, and many more.
- Images Lazy Loading: Swiper Lazy Loading delays loading of images in inactive/invisible slides until the user swipes to them. Such feature could make the page load faster and improve Swiper performance.
- Virtual Slides: Swiper comes with Virtual Slides feature that is great when you have a lot of slides or content-heavy/image-heavy slides so it will keep just the required amount of slides in DOM.
- Loop mode
- Autoplay
- Keyboard control
- Mousewheel control
- Nested sliders
- History navigation
- Hash navigation
- Breakpoints configuration
- Accessibility (A11y)
- And many more ...
Community
The Swiper community can be found on GitHub Discussions, where you can ask questions, voice ideas, and share your projects
Our Code of Conduct applies to all Swiper community channels.
Dist / Build
On production use files (JS and CSS) only from dist/
folder, there will be the most stable versions.
Development Build
Install all dependencies, in repo's root:
$ npm install
And build development version of Swiper:
$ npm run build
The result is available in dist/
folder.
Running demos:
All demos located in ./playground
folder. There you will find Core (HTML, JS), React, Vue versions.
To open demo, run:
- Core:
npm run core
- React:
npm run react
- Vue:
npm run vue
Production Build
$ npm run build:prod
Production version will available in dist/
folder.
Contributing
All changes should be committed to src/
files only. Before you open an issue please review the contributing guideline.
Major Roadmapped Features
- Top Feature Requests (Add your own votes using the ð reaction)
- Top Bugs ð± (Add your own votes using the ð reaction)
Contributors
Code Contributors
This project exists thanks to all the people who contribute. [Contribute].
Financial Contributors
Become a financial contributor and help us sustain our community. [Contribute]
Top Related Projects
the last carousel you'll ever need
A dependency-free JavaScript ES6 slider and carousel. It’s lightweight, flexible and fast. Designed to slide. No less, no more
Splide is a lightweight, flexible and accessible slider/carousel written in TypeScript. No dependencies, no Lighthouse errors.
A lightweight carousel library with fluid motion and great swipe precision.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot