@uttamkn/image_carousel

1.0.0 • Public • Published

Image Carousel

A lightweight, customizable image carousel component for web applications. Supports automatic slide transitions, navigation controls, and dot indicators.

Features

  • Automatic slide transitions with customizable interval.
  • Navigation controls to move to the next or previous slide.
  • Dot indicators for direct slide selection.
  • Pause on hover functionality.

Installation

Install the package via npm:

npm install @uttamkn/image_carousel

API

getCarousel(parentElement, slides, maxWidth)

  • parentElement: The DOM element where the carousel will be appended.
  • slides: An array of image URLs.
  • maxWidth (optional): The maximum width of the carousel (default is 600px).

Usage

Include a container element in your HTML where the carousel will be rendered:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Carousel Example</title>
  </head>
  <body>
    <div id="carousel-container"></div>
    <script type="module" src="main.js"></script>
  </body>
</html>

Import the carousel function and initialize it with your slides:

// main.js

import getCarousel from "@uttamkn/image_carousel";

const slides = ["image1.jpg", "image2.jpg", "image3.jpg"];

document.addEventListener("DOMContentLoaded", () => {
  const container = document.getElementById("carousel-container");
  getCarousel(container, slides);
});

Customization

You can customize the maximum width of the carousel by passing an additional argument:

getCarousel(container, slides, 800); // Set max-width to 800px

Readme

Keywords

none

Package Sidebar

Install

npm i @uttamkn/image_carousel

Weekly Downloads

2

Version

1.0.0

License

ISC

Unpacked Size

5.71 kB

Total Files

3

Last publish

Collaborators

  • uttamkn