Zazz Design Framework
Components

Carousel

Draggable, looping carousels built with Embla and the ui-carousel custom element.

<ui-carousel> initializes an Embla carousel with markup-driven options, drag interactions, looping, keyboard navigation, and thumbnail synchronization.

Default

Loading components…

Anatomy

The root is the <ui-carousel> element itself; interior parts are marked with data-slot="carousel-{part}". Set slide widths with basis-* utilities:

<ui-carousel data-carousel-loop="true">
  <div data-slot="carousel-viewport">
    <div data-slot="carousel-container">
      <div data-slot="carousel-slide" class="basis-full @sm:basis-1/2 @md:basis-1/3">Slide 1</div>
      <div data-slot="carousel-slide" class="basis-full @sm:basis-1/2 @md:basis-1/3">Slide 2</div>
      <div data-slot="carousel-slide" class="basis-full @sm:basis-1/2 @md:basis-1/3">Slide 3</div>
    </div>
  </div>
  <button type="button" data-slot="carousel-prev">Prev</button>
  <button type="button" data-slot="carousel-next">Next</button>
</ui-carousel>
data-slot valuePurpose
carousel-viewportVisible window (required)
carousel-containerFlex track for slides
carousel-slideIndividual slide item
carousel-prev / carousel-nextNavigation buttons (optional)
carousel-dots / carousel-dotPagination container and template dot (optional)
carousel-thumbsSynchronized thumbnail container (optional)

data-slot is a space-separated token list, so an element can serve two primitives at once: a lightbox slide is also a carousel slide (data-slot="lightbox-slide carousel-slide"). Selectors match slots with [data-slot~="carousel-slide"].

Setup

Load index.js as an ES module:

<script type="module" src="./zazz/index.js"></script>

Third-party dependencies (Embla core and plugins) resolve through the <script type="importmap"> in <head>.

Options

Configure Embla options as data-carousel-* attributes on <ui-carousel>:

AttributePurpose
data-carousel-loopSet to "true" for infinite loop
data-carousel-alignstart, center, or end
data-carousel-keyboardSet to "false" to disable keys

Plugins

Enable plugins with a space-separated data-carousel-plugins list. Configure each plugin with its option prefix; setting options alone will not load the plugin.

<ui-carousel data-carousel-plugins="autoplay" data-carousel-autoplay-delay="3000">
  ...
</ui-carousel>
PluginSlugOptions prefixPackage specifier
Autoplayautoplaydata-carousel-autoplay-*embla-carousel-autoplay
Auto Scrollauto-scrolldata-carousel-auto-scroll-*embla-carousel-auto-scroll
Class Namesclass-namesdata-carousel-class-names-*embla-carousel-class-names

Dots pagination

<div data-slot="carousel-dots">
  <button type="button" data-slot="carousel-dot"></button>
</div>

The script clones the template button for each slide and toggles .is-active.

Thumbnail navigation

Nest a data-slot="carousel-thumbs" container inside <ui-carousel> for synchronized thumbnail strips.

Dialog integration

Carousels inside closed <dialog> elements defer initialization until the modal opens. Add data-carousel-start="2" to the trigger button to open at an exact slide.

Dynamic re-initialization

After inserting new HTML into the page:

EmblaInit.init(containerElement);

On this page