<divs>

Components
  • All
  • Carousel
    13 Variants
  • Marquee
    14 Variants
More coming... let me cook

Hi, I'm Idrees.

Founder of Mumino.

I built all components and this site's full stack myself, for fun. Imagine what we can do with a budget.

Book a Call

Connect

Work With Us

Made by Idrees Isse

Founder of Mumino, a digital design & development agency.

Available for hire.

@idreezus

FeaturesSetupHow It WorksStructureWebflow CMSVariantsContent CardsFeature CardsGalleriesTestimonialsCustomizationCore AttributesNavigation ElementsKeyboard NavigationSpacing and PositioningState ClassesJavaScript APIManual InitializationInstance MethodsEventsGlobal RegistryDynamic ContentFAQ
Components

Carousel

A lightweight slider that leverages native CSS for smooth snap-scrolling and flexible styling.

0 Variants
Note:Your window size is small – the preview may not be fully visible. Try checking it out on a larger screen.
Navigator
No node selected
Select a node from the Navigator to view its details, attributes, and styles.

Features

  • Flexible item sizing with automatic recalculations across breakpoints
  • Simple setup: navigation buttons and keyboard controls work with minimal markup
  • Allows for multiple carousels per page without initialization conflicts
  • Native CSS gives performant, GPU-accelerated scrolling
  • Javascript API and events available for complex builds

Setup

Copy & paste this script in your Page Settings Before </body>Copy tag

HTML
<!-- Divs Carousel Library -->
<script src="https://cdn.jsdelivr.net/gh/idreezus/divs@v1.0.0/dist/carousel/v1.0.0/carousel.min.js"></script>

Copy & paste this in an embed element or your Page Settings Inside <head>Copy tag

CSS
/* Things you could change */
:root {
  --site-max-width: 80rem; /* your site's container width here */
  --site-padding: 2.5rem; /* your site's padding here */
}
 
@media (max-width: 767px) {
  :root {
    --site-padding: 1.25rem; /* your site's padding on mobile (landscape) and below */
  }
}
 
/*
*	Things for nerds
*/
 
/* Variables used in the `.carousel_track` `.carousel_track.is-breakout` classes */
:root {
  --carousel-scroll-padding: calc(
    (100% - min(var(--site-max-width), 100% - var(--site-padding) * 2)) / 2
  );
  --carousel-scroll-padding-breakout: calc(
    (100vw - min(var(--site-max-width), 100vw - var(--site-padding) * 2)) / 2
  );
}
 
@media (max-width: 767px) {
  :root {
    --carousel-scroll-padding: calc(
      (100% - min(var(--site-max-width), 100% - var(--site-padding) * 2)) / 2
    );
    --carousel-scroll-padding-breakout: calc(
      (100vw - min(var(--site-max-width), 100vw - var(--site-padding) * 2)) / 2
    );
  }
}
 
/* Hide scrollbar in WebKit browsers */
[data-carousel="track"]::-webkit-scrollbar {
  display: none;
}
 
[data-carousel="track"].carousel-snap-disabled {
  scroll-snap-type: none;
}
 
@media (prefers-reduced-motion: reduce) {
  [data-carousel="track"] {
    scroll-behavior: auto !important;
  }
}
 
/* Default alignment when no attributes set */
[data-carousel="container"]:not([data-carousel-align]) [data-carousel="item"] {
  scroll-snap-align: start;
}
 
[data-carousel-align="start"] [data-carousel="item"] {
  scroll-snap-align: start;
}
 
[data-carousel-align="center"] [data-carousel="item"] {
  scroll-snap-align: center;
}
 
[data-carousel-align="end"] [data-carousel="item"] {
  scroll-snap-align: end;
}
 
/* Screen reader only utility for visually hidden live region */
.carousel-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

Grab a variant below, or continue reading the documentation if you want to learn more (pls do it's hard to write documentation).

How It Works

I started coding a carousel library on top of SwiperJS for days until I remembered how difficult it always is to work with – especially when it came to controlling the styling. So I threw that library in the trash.

This new library was made to be easy to work with (especially on Webflow) without fighting unexpected Javascript shenanigans. You style things like always and control item sizes and spacing with standard CSS properties.

In the background, ResizeObserverCopy detects changes and automatically recalculates positions and boundaries. CSS Scroll Snap handles alignment. scrollIntoView()Copy provides the smooth programmatic navigation.

The benefit of leveraging native browser features instead of a library like SwiperJS is that the carousel gets GPU acceleration and performance optimizations for free. And it's just smoother. Less JavaScript, better performance, smoother scrolling.

Structure

There's three elements required:

  • [data-carousel="container"]Copy – the outermost container, used for scoping a specific instance.
  • [data-carousel="track"]Copy – the horizontal list that houses all the items.
  • [data-carousel="item"]Copy – the individual slides.

The purpose of the [data-carousel="container"]Copy element is three-fold:

  • It allows for automatic unique instance detection. Translation: you can simply have elements like the previous/next navigation buttons exist within the [data-carousel="container"]Copy , and the code already knows those buttons are for that specific carousel. It won't randomly start moving another carousel on another part of the page.
  • It works perfectly with Webflow CMS. How do you get navigation buttons inside Webflow's Collection List if you can't put non-CMS things inside a Collection List? Exactly. Now you can.
  • Flexibility for future features. Wink.
Important

You can put whatever you want inside of the [data-carousel="container"]Copy element. The [data-carousel="track"]Copy can be nested arbitrarily deep.

The only restraints: there can only be one carousel within a container, and all the [data-carousel="item"]Copy elements must be direct children of the track.

Webflow CMS

To match up with the Webflow Collection List structure:

  1. [data-carousel="container"]Copy – goes on the Collection List WrapperCopy (if you don't care for navigation buttons), or anywhere as an ancestor of the Collection List WrapperCopy.
  2. [data-carousel="track"]Copy – goes on the Collection ListCopy
  3. [data-carousel="item"]Copy – goes on the (you guessed it!) Collection List ItemCopy
HTML
<div data-carousel="container">
  <div data-carousel="track">
    <div data-carousel="item">Item 1</div>
    <div data-carousel="item">Item 2</div>
    <div data-carousel="item">Item 3</div>
  </div>
  <div>
    <button data-carousel="prev">Previous</button>
    <button data-carousel="next">Next</button>
  </div>
</div>

Variants

Content Cards

Note:Your window size is small – the preview may not be fully visible. Try checking it out on a larger screen.
Navigator
No node selected
Select a node from the Navigator to view its details, attributes, and styles.
Note:Your window size is small – the preview may not be fully visible. Try checking it out on a larger screen.
Navigator
No node selected
Select a node from the Navigator to view its details, attributes, and styles.
Note:Your window size is small – the preview may not be fully visible. Try checking it out on a larger screen.
Navigator
No node selected
Select a node from the Navigator to view its details, attributes, and styles.
Note:Your window size is small – the preview may not be fully visible. Try checking it out on a larger screen.
Navigator
No node selected
Select a node from the Navigator to view its details, attributes, and styles.
Note:Your window size is small – the preview may not be fully visible. Try checking it out on a larger screen.
Navigator
No node selected
Select a node from the Navigator to view its details, attributes, and styles.
Note:Your window size is small – the preview may not be fully visible. Try checking it out on a larger screen.
Navigator
No node selected
Select a node from the Navigator to view its details, attributes, and styles.

Feature Cards

Note:Your window size is small – the preview may not be fully visible. Try checking it out on a larger screen.
Navigator
No node selected
Select a node from the Navigator to view its details, attributes, and styles.
Note:Your window size is small – the preview may not be fully visible. Try checking it out on a larger screen.
Navigator
No node selected
Select a node from the Navigator to view its details, attributes, and styles.

Galleries

Note:Your window size is small – the preview may not be fully visible. Try checking it out on a larger screen.
Navigator
No node selected
Select a node from the Navigator to view its details, attributes, and styles.
Note:Your window size is small – the preview may not be fully visible. Try checking it out on a larger screen.
Navigator
No node selected
Select a node from the Navigator to view its details, attributes, and styles.
Note:Your window size is small – the preview may not be fully visible. Try checking it out on a larger screen.
Navigator
No node selected
Select a node from the Navigator to view its details, attributes, and styles.

Testimonials

Note:Your window size is small – the preview may not be fully visible. Try checking it out on a larger screen.
Navigator
No node selected
Select a node from the Navigator to view its details, attributes, and styles.
Note:Your window size is small – the preview may not be fully visible. Try checking it out on a larger screen.
Navigator
No node selected
Select a node from the Navigator to view its details, attributes, and styles.

Customization

Core Attributes

Configure the carousel with data attributes on the container element:

AttributeValuesDefaultDescription
data-carouselCopy"container"Copy-Required on container element
data-carouselCopy"track"Copy-Required on track element
data-carouselCopy"item"Copy-Required on each item element
data-carousel-alignCopy"start"Copy / "center"Copy / "end"Copy"start"CopySnap alignment of items
data-carousel-keyboardCopy"true"Copy / "false"Copy"false"CopyEnable keyboard navigation

Navigation Elements

Optional navigation controls that work automatically when placed inside the container:

AttributeDescription
data-carousel="prev"CopyPrevious button
data-carousel="next"CopyNext button
Note

Pagination is coming very soon. Doing some bug testing.

Keyboard Navigation

When enabled, Arrow LeftCopy and Arrow RightCopy navigate between items. For those with huge keyboards, HomeCopy jumps to first item and EndCopy jumps to the last item.

To enable keyboard navigation:

HTML
<div data-carousel="container" data-carousel-keyboard="true">
  <!-- Rest of the track/items -->
</div>

Spacing and Positioning

Use CSS gapCopy on the [data-carousel="track"]Copy to control spacing.

The library also works with CSS scroll-paddingCopy (container insets) and scroll-marginCopy (per-item offsets) for controlling snap positioning. For the variants on this page, all of them have scroll-paddingCopy on the track element.

State Classes

The library applies state classes that you can style however you want.

ClassApplied to
.carousel-item-activeCopyThe item that is currently active (i.e. aligned)
.carousel-button-disabledCopyNavigation buttons at start/end boundaries
.carousel-scrollingCopyThe track while a user or programmatic scrolling is active
.carousel-snap-disabledCopyThe track to temporarily disable scroll-snap during button navigation
.carousel-animatingCopyThe track during programmatic scroll animations
.carousel-pagination-activeCopyThe active pagination dot

Here's an example from the prev/next buttons on all the variants on this page:

CSS
/* Arrow initial styles */
.carousel_arrow {
  cursor: pointer;
  transition:
    opacity 200ms ease-in-out,
    color 150ms ease-in-out;
}
 
/* For a disabled arrow */
[data-carousel="container"] .carousel_arrow.carousel-button-disabled {
  cursor: default;
  opacity: 0.5;
}
 
/* Brighten up the not-disabled arrow on hover */
.carousel_arrow:not(.carousel-button-disabled):hover {
  color: color-mix(in srgb, currentColor 100%, transparent);
}

JavaScript API

Manual Initialization

JavaScript
// Auto-initializes on page load by default
// Or manually initialize:
const carousel = new Carousel(
  document.querySelector('[data-carousel="container"]'),
);
 
// Or using selector:
const carousel = Carousel.init(".my-carousel");

Instance Methods

JavaScript
carousel.next(); // Go to next item
carousel.prev(); // Go to previous item
carousel.goTo(2); // Go to specific index (0-based)
carousel.getActiveIndex(); // Returns current index
carousel.refresh(); // Recalculate dimensions and update
carousel.destroy(); // Clean up and remove listeners

All methods are chainable:

JavaScript
carousel.next().next().refresh();

Events

JavaScript
carousel.on("change", (e) => {
  console.log(`Active item: ${e.index}`);
});
 
carousel.on("scroll", (e) => {
  console.log(`Scroll position: ${e.scrollLeft}px`);
});
 
carousel.on("reach-start", () => {
  console.log("At first item");
});
 
carousel.on("reach-end", () => {
  console.log("At last item");
});
 
// Remove listener
carousel.off("change", handler);

Or use native DOM events:

JavaScript
container.addEventListener("carousel:change", (e) => {
  console.log(e.detail); // { carousel, index }
});

Available events:

EventDescriptionEvent Data
changeCopyActive item changed{ index }Copy
scrollCopyTrack scrolled{ scrollLeft }Copy
reach-startCopyScrolled to first item-
reach-endCopyScrolled to last item-

Global Registry

Access all carousel instances:

JavaScript
// Get all instances
const instances = window.CarouselInstances;
 
// Get specific instance by ID
const carousel = instances.get("carousel-1");
 
// Iterate over all
instances.forEach((carousel) => {
  console.log(carousel.id, carousel.getActiveIndex());
});

Dynamic Content

When adding/removing items, call refresh()Copy:

JavaScript
const track = carousel.track;
const newItem = document.createElement("div");
newItem.setAttribute("data-carousel", "item");
newItem.textContent = "New Item";
track.appendChild(newItem);
 
carousel.refresh(); // Recalculate positions

For major structural changes, destroy and reinitialize:

JavaScript
carousel.destroy();
const newCarousel = new Carousel(container);

FAQ

Does it work vertically?
Not yet. Wink.
How do I style my navigation buttons at the edges?

The library automatically adds the .carousel-button-disabledCopy class when at the start or end. Style that class however you like.

CSS
button[data-carousel].carousel-button-disabled {
  opacity: 0.3;
  pointer-events: none;
}
Can I customize the animation duration?

The library uses native scroll-behavior: smoothCopy, so animation timing is controlled by the browser. For custom timing, you'd need to implement custom scrolling instead of using the native behavior.

What if my carousel is initially hidden?

Call refresh()Copy when the carousel becomes visible:

JavaScript
// When showing carousel
carousel.refresh();
Why are my buttons not working?

Check the console for warnings. The library logs clear messages for the most common situations (like missing elements). Each carousel also has a data-carousel-idCopy attribute for easier debugging in DevTools. If you still have questions, feel free to reach out to me.

Why do you call it 'Carousel' instead of 'Slider'?

Great question. I called it Slider my whole life (I still do), but I learned it's not the right semantics. The browser world (like Chrome and Mozilla devs) call it "Carousel" since "Slider" is reserved for things like an input range slider. And I might want to make an input range slider component in the future. So I had to lock in and leave the /sliderCopy URL free.