Installation of Swiper.js

Method 1: Using CDN

You can get started using Swiper.js fastest with a Content Delivery Network (CDN) and without requiring any build tools or package managers-

Include Swiper.js CSS in head tag-

<link rel="stylesheet" href="https://www.w3wiki.nethttps://unpkg.com/swiper/swiper-bundle.min.css">

Include Swiper.js JavaScript:

<script src="https://unpkg.com/swiper/swiper-bundle.min.js"></script>

Method 2: Using npm

A popular package manager for JavaScript, npm, lets you include Swiper.js in your projects as a dependency.

Install Swiper.js: Install Swiper.js using the following command-

npm install swiper

Import Swiper.js in Your JavaScript: Import Swiper.js and its CSS in your JavaScript file.

import Swiper from 'swiper/bundle';
import 'swiper/swiper-bundle.css';

// Initialize Swiper
const swiper = new Swiper('.swiper-container', {
// Swiper options
});

Example: In the given below example will see the basic usage of Swiper.js.

HTML
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,
                   initial-scale=1">
    <title>Infinity Swiper Effect Using Swiper.js</title>
    <link rel="stylesheet" href="
https://unpkg.com/swiper/swiper-bundle.min.css" />
    <style type="text/css">
        .swiper-container {
            width: 100%;
            padding-top: 50px;
            padding-bottom: 50px;
        }

        .swiper-slide {
            background-position: center;
            background-size: cover;
            width: 300px;
        }

        .swiper-slide img {
            display: block;
            width: 100%;
        }
    </style>
</head>

<body>
    <div class="swiper-container mySwiper">
        <div class="swiper-wrapper">
            <div class="swiper-slide">
                <img src=
"https://media.w3wiki.org/wp-content/uploads/20240605120007/GFG-logo.jpg" />
            </div>
            <div class="swiper-slide">
                <img
                    src=
"https://media.w3wiki.org/wp-content/uploads/20240606102206/Transport-of-Carbon-Dioxide-in-the-Blood.png" />
            </div>
            <div class="swiper-slide">
                <img
                    src=
"https://media.w3wiki.org/wp-content/uploads/20240606103259/Use-Cases-of-Computer-Vision-in-Manufacturing.webp" />
            </div>
            <div class="swiper-slide">
                <img
                    src=
"https://media.w3wiki.org/wp-content/uploads/20240606102721/How-To-Make-Your-Friends-Hear-Your-Music-On-Discord.webp" />
            </div>
            <div class="swiper-slide">
                <img
                    src=
"https://media.w3wiki.org/wp-content/uploads/20240606102908/Best-Portfolio-Websites.webp" />
            </div>

            <div class="swiper-slide">
                <img
                    src=
"https://media.w3wiki.org/wp-content/uploads/20240606091054/mass_flow_hypothesis_50.webp" />
            </div>
        </div>
    </div>
    <script src="https://unpkg.com/swiper/swiper-bundle.min.js"></script>
    <script>
        let swiper = new Swiper(".mySwiper", {
            effect: "coverflow",
            grabCursor: true,
            centeredSlides: true,
            slidesPerView: "auto",
            coverflowEffect: {
                rotate: 10,
                stretch: 10,
                depth: 200,
                modifier: 1,
                slideShadows: true,
            },

            loop: true,
        });
    </script>
</body>

</html>

Output:

SwiperJS

Similar Reads

What is Swiper.js?

Swiper.js is an advanced and potent JavaScript library intended for producing touch-enabled sliders, carousels as well as galleries that are used extensively in both web and mobile applications in order to ensure a smooth and interesting experience, also, it is worth noting that this tool is especially in high demand for the creation of mobile-friendly websites because it works with touch gestures, that’s why it includes various functionalities and possibilities for fine-tuning, thus enabling its employment in many contexts....

Uses of Swiper.js

In multiple scenarios, Swiper.js is flexible and can be used for user enhancements in web and mobile applications, some of these are-...

Advantages of Swiper.js

There are several advantages that make Swiper.js a preferred choice for making sliders, carousels and galleries in web and mobile apps, here are some of its main benefits-...

Drawbacks of Swiper.js

There are several reasons why Swiper.js can be favored by some developers, but it also has some drawbacks that should be kept in mind before integrating it into a project, here are a few of the main disadvantages-...

Swiper Core/API

Swiper Core is the foundation of Swiper.js, which comprises all the important features and settings needed for creating and modifying sliders, it is coded in pure JavaScript without dependence on any other library, the core API offers vast options to control the behavior and style of a slider such as-...

Swiper Element

Swiper Element is a web component that wraps Swiper.js such that you can use it as a custom HTML element, this approach helps simplify using Swiper with or without frameworks via web components, its main advantages are-...

Swiper React

Swiper React is an official React.js wrapper for Swiper.js, providing React components for easy integration of Swiper in React applications, you can integrate Swiper while leveraging React’s entire state management capabilities and lifecycle methods, these include-...

Swiper Vue

Swiper Vue is an official Vue.js wrapper for Swiper.js, offering Vue components to make integrating with Vue applications easier, it uses Vue’s reactivity along with its templating engine to ensure seamless integration with smooth outcomes, key features include-...

Installation of Swiper.js

Method 1: Using CDN...

Conclusion

Swiper.js is a strong, adaptable library of JavaScript which is good at creating mobile and desktop slideshows touch-enabled or carousel sliders, it has become a popular preference for many programmers because they can easily add touch gestures and customize it without much trouble, Swiper.js is very responsive to mobile devices; it therefore guarantees optimal user interactivity and responsiveness, it can as well be customized for use in different applications which make it versatile because it is made using modern web technology techniques so as to ensure that users have a good experience regardless of their devices....