A lightweight, responsive, and feature-rich JavaScript carousel library with zero dependencies.
npm install easy-carousel
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@nikba/easy-carousel/dist/easy-carousel.min.css">
<script src="https://cdn.jsdelivr.net/npm/@nikba/easy-carousel/dist/easy-carousel.min.js"></script>
<div class="my-carousel">
<img src="slide1.jpg" alt="Slide 1">
<img src="slide2.jpg" alt="Slide 2">
<img src="slide3.jpg" alt="Slide 3">
</div>
<script>
const carousel = new EasyCarousel('.my-carousel', {
items: 3,
margin: 20,
loop: true,
nav: true,
dots: true
});
</script>
Option | Type | Default | Description |
---|---|---|---|
items |
number | 3 | Number of items to show |
margin |
number | 0 | Space between items (px) |
loop |
boolean | false | Infinite loop mode |
nav |
boolean | false | Show navigation arrows |
dots |
boolean | true | Show navigation dots |
autoplay |
boolean | false | Enable autoplay |
autoplayTimeout |
number | 5000 | Autoplay interval (ms) |
mouseDrag |
boolean | true | Enable mouse drag |
touchDrag |
boolean | true | Enable touch swipe |
responsive |
object | {} | Responsive breakpoints config |
Automatically handles window resize events for responsive layouts
Handles mouse click and drag events for slide navigation
Manages touch start, move, and end events for mobile devices
Left/Right arrow keys for slide navigation
Handles play, pause, and hover pause functionality
Click events for dot indicators
If you find Easy Carousel helpful, consider supporting its development!
Buy me a coffee