Free Spring Slider with Swiper.js- HTML and React Snippets

Spring Slider code

Introduction to Swiper js and Spring Slider

With support for a variety of effects, transitions, and customizable features, Swiper.js stands out as a go-to solution for enhancing user interactions.

One of the unique implementations using Swiper.js is the Spring Slider. This slider leverages the power of Swiper.js, combined with the dynamic and smooth animations from React Spring, to create a visually appealing and interactive sliding experience.

The Spring Slider brings a touch of elegance to any project, offering seamless transitions that are both smooth and responsive. Whether you’re looking to showcase a portfolio, display products, or create an engaging slideshow, the Spring Slider with Swiper.js is a perfect choice to add a modern and professional touch to your web design.

In this blog, we’ll explore how to set up the Spring Slider using Swiper.js, and provide you with HTML and React code snippets to get started quickly. Whether you’re a seasoned developer or just getting started, you’ll find these snippets helpful for integrating this stunning slider into your projects.

Spring Slider

The Spring Slider is a versatile and visually dynamic slider component that combines the robust capabilities of Swiper.js with the smooth animations provided by React Spring. Designed to deliver a seamless and interactive user experience, the Spring Slider is ideal for a wide range of use cases.

Its main focus is on categories like portfolios, product showcases, and image galleries where visual appeal and user engagement are paramount. The slider’s ability to handle complex transitions with ease makes it a perfect fit for websites that require a polished and professional presentation of content.

Targeted primarily at web developers and designers, the Spring Slider is particularly useful for those working on projects that demand high-quality, responsive, and mobile-friendly sliders.

Whether you’re developing a personal portfolio, a company website, or an e-commerce platform, the Spring Slider offers a powerful tool to enhance your site’s interactivity and user engagement. Its customizable features and easy integration make it a go-to choice for professionals seeking to create captivating and modern web interfaces.

Spring Slider – HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script
      type="module"
      crossorigin
      src="https://spring-slider.uiinitiative.com/assets/index.8742a0a0.js"
    ></script>
    <link
      rel="modulepreload"
      href="https://spring-slider.uiinitiative.com/assets/vendor.0e76e1a6.js"
    />
    <link
      rel="stylesheet"
      href="https://spring-slider.uiinitiative.com/assets/index.a155cde7.css"
    />
  </head>
  <body>
    <div class="" style="height: 100vh;display: flex;align-items: center; margin: 0 52px; " >
      <div class="spring-slider    " style="cursor: grab; ">
        <div class="swiper">
          <div class="swiper-wrapper">
            <div class="swiper-slide">
              <img
                src="https://cdn.pixabay.com/photo/2023/03/22/07/52/lizard-7868932_1280.jpg"
                alt=""
              />
            </div>
            <div class="swiper-slide">
              <img
                src="https://cdn.pixabay.com/photo/2023/10/10/15/37/motorcycle-8306765_1280.jpg"
                alt=""
              />
            </div>
            <div class="swiper-slide">
              <img
                src="https://cdn.pixabay.com/photo/2023/03/17/02/42/architecture-7857832_1280.jpg"
                alt=""
              />
            </div>
            <div class="swiper-slide">
              <img
                src="https://cdn.pixabay.com/photo/2021/09/27/20/47/nature-6662283_1280.jpg"
                alt=""
              />
            </div>
            <div class="swiper-slide">
              <img
                src="https://cdn.pixabay.com/photo/2019/06/24/16/43/mountain-4296464_1280.jpg"
                alt=""
              />
            </div>
            <div class="swiper-slide">
              <img
                src="https://cdn.pixabay.com/photo/2024/01/18/14/46/train-8517089_1280.jpg"
                alt=""
              />
            </div>
            <div class="swiper-slide">
              <img
                src="https://cdn.pixabay.com/photo/2023/07/08/09/53/monastery-8114076_1280.jpg"
                alt=""
              />
            </div>
            <div class="swiper-slide">
              <img
                src="https://cdn.pixabay.com/photo/2016/06/17/04/26/mountain-1462655_1280.jpg"
                alt=""
              />
            </div>
            <div class="swiper-slide">
              <img
                src="https://cdn.pixabay.com/photo/2021/10/11/18/58/lake-6701636_1280.jpg"
                alt=""
              />
            </div>
            <div class="swiper-slide">
              <img
                src="https://cdn.pixabay.com/photo/2019/01/16/11/18/russia-3935761_1280.jpg"
                alt=""
              />
            </div>
          </div>
          <div class="swiper-button-prev"></div>
          <div class="swiper-button-next"></div>
        </div>
        <div class="swiper-pagination"></div>
      </div>
    </div>
  </body>
</html>

Spring Slider – React

import React, { useEffect } from "react";

const Spring = () => {
  useEffect(() => {
    // Add the external CSS link
    const link = document.createElement("link");
    link.rel = "stylesheet";
    link.href =
      "https://spring-slider.uiinitiative.com/assets/index.a155cde7.css";
    document.head.appendChild(link);

    // Add the module preload link
    const preloadLink = document.createElement("link");
    preloadLink.rel = "modulepreload";
    preloadLink.href =
      "https://spring-slider.uiinitiative.com/assets/vendor.0e76e1a6.js";
    document.head.appendChild(preloadLink);

    // Add the external script
    const script = document.createElement("script");
    script.type = "module";
    script.crossOrigin = "anonymous";
    script.src =
      "https://spring-slider.uiinitiative.com/assets/index.8742a0a0.js";
    document.body.appendChild(script);

    // Cleanup script and links on unmount
    return () => {
      document.head.removeChild(link);
      document.head.removeChild(preloadLink);
      document.body.removeChild(script);
    };
  }, []);

  return (
    <>
      <div className="flex justify-center items-center  mx-auto h-screen ">
        <div className="spring-slider cursor-grab ">
          <div className="swiper">
            <div className="swiper-wrapper">
              <div className="swiper-slide ">
                <img
                  className="slide-image rounded-md"
                  src="https://cdn.pixabay.com/photo/2020/12/01/18/06/porsche-911-gt2-5795128_1280.jpg"
                  alt="Slide 1"
                />
              </div>
              <div className="swiper-slide ">
                <img
                  className="slide-image rounded-md"
                  src="https://cdn.pixabay.com/photo/2024/08/14/07/05/building-8967854_1280.jpg"
                  alt="Slide 2"
                />
              </div>
              <div className="swiper-slide ">
                <img
                  className="slide-image rounded-md"
                  src="https://cdn.pixabay.com/photo/2014/09/07/22/34/car-race-438467_1280.jpg"
                  alt="Slide 2"
                />
              </div>
              <div className="swiper-slide ">
                <img
                  className="slide-image rounded-md"
                  src="https://cdn.pixabay.com/photo/2020/09/06/07/37/car-5548242_1280.jpg"
                  alt="Slide 2"
                />
              </div>
              <div className="swiper-slide ">
                <img
                  className="slide-image rounded-md"
                  src="https://cdn.pixabay.com/photo/2016/02/13/13/11/oldtimer-1197800_1280.jpg"
                  alt="Slide 2"
                />
              </div>
              <div className="swiper-slide ">
                <img
                  className="slide-image rounded-md"
                  src="https://cdn.pixabay.com/photo/2024/07/20/05/24/poppy-8907588_1280.jpg"
                  alt="Slide 2"
                />
              </div>
              <div className="swiper-slide ">
                <img
                  className="slide-image rounded-md"
                  src="https://cdn.pixabay.com/photo/2020/12/01/18/06/porsche-911-gt2-5795128_1280.jpg"
                  alt="Slide 1"
                />
              </div>
              <div className="swiper-slide ">
                <img
                  className="slide-image rounded-md"
                  src="https://cdn.pixabay.com/photo/2024/08/14/07/05/building-8967854_1280.jpg"
                  alt="Slide 2"
                />
              </div>
              <div className="swiper-slide ">
                <img
                  className="slide-image rounded-md"
                  src="https://cdn.pixabay.com/photo/2014/09/07/22/34/car-race-438467_1280.jpg"
                  alt="Slide 2"
                />
              </div>
            </div>
            <div className="swiper-pagination">l</div>
          </div>
        </div>
      </div>
    </>
  );
};

export default Spring;

Notes: Since the Swiper.js Spring theme is part of a paid plan, the above code snippets use custom coding with CDNs instead of relying on the Swiper.js library, which doesn’t offer this premium effect for free.

If you’re looking to create another masterpiece slider, you should definitely check out the Panorama Slider. Simply click the bold text to explore its features and see how it can transform your project.

Scroll to Top