# Carousel

> One slide at a time with previous/next controls and a roving dot group.

- Tier: free, MIT
- Category: Data display
- Docs: https://ui.mlola.com/docs/components/carousel

## Install

```bash
npx mlola-ui add carousel
```

```tsx
import { Carousel } from "@/components/ui/carousel";
```

## Props with fixed values

| Component | Prop | Values | Default | Description |
| --- | --- | --- | --- | --- |
| Carousel | `indicators` | `dots`, `counter`, `none` | `dots` | Dots under the slides, a counter, or nothing. |

## Example

```tsx
import { Carousel } from "@/components/ui/carousel";

const slides = ["Plan", "Build", "Ship"].map((title) => (
  <div key={title} className="ml-card" data-variant="elevated">
    <div className="ml-card-content">{title}</div>
  </div>
));

export default function Example() {
  return <Carousel label="Release stages" items={slides} itemLabels={["Plan", "Build", "Ship"]} />;
}
```

## The same markup without React

```html
<div class="ml-carousel" role="group" aria-roledescription="carousel" aria-label="Release stages" data-arrows="true" style="--ml-carousel-per-view:1;--ml-carousel-peek:0px;--ml-carousel-min:0px;--ml-carousel-autoplay:0ms">
  <div class="ml-carousel-viewport">
    <div class="ml-carousel-track" tabindex="0" aria-label="Release stages, use the arrow keys">
      <div class="ml-carousel-slide" role="group" aria-roledescription="slide" aria-label="1 of 3: Plan" data-current="true">
        <div class="ml-card" data-variant="elevated"><div class="ml-card-content">Plan</div></div>
      </div>
      <div class="ml-carousel-slide" role="group" aria-roledescription="slide" aria-label="2 of 3: Build">
        <div class="ml-card" data-variant="elevated"><div class="ml-card-content">Build</div></div>
      </div>
      <div class="ml-carousel-slide" role="group" aria-roledescription="slide" aria-label="3 of 3: Ship">
        <div class="ml-card" data-variant="elevated"><div class="ml-card-content">Ship</div></div>
      </div>
    </div>
    <button class="ml-carousel-arrow" type="button" data-side="previous" aria-label="Previous slide"><svg class="mlola-glyph" width="1.1em" height="1.1em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="var(--mlola-glyph-stroke, var(--ml-icon-stroke, 1.75))" stroke-linecap="round" stroke-linejoin="round" focusable="false" aria-hidden="true" data-optical-size="default" style="color:var(--mlola-glyph-color, currentColor);scale:var(--mlola-glyph-optical-scale, 1);transform-origin:center"><path d="m15 18-6-6 6-6" pathLength="1"></path></svg></button>
    <button class="ml-carousel-arrow" type="button" data-side="next" aria-label="Next slide"><svg class="mlola-glyph" width="1.1em" height="1.1em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="var(--mlola-glyph-stroke, var(--ml-icon-stroke, 1.75))" stroke-linecap="round" stroke-linejoin="round" focusable="false" aria-hidden="true" data-optical-size="default" style="color:var(--mlola-glyph-color, currentColor);scale:var(--mlola-glyph-optical-scale, 1);transform-origin:center"><path d="m9 18 6-6-6-6" pathLength="1"></path></svg></button>
  </div>
  <div class="ml-carousel-dots" role="group" aria-label="Choose release stages">
    <button class="ml-carousel-dot" type="button" data-hit="expand" aria-current="true" aria-label="Plan" tabindex="0"></button>
    <button class="ml-carousel-dot" type="button" data-hit="expand" aria-label="Build" tabindex="-1"></button>
    <button class="ml-carousel-dot" type="button" data-hit="expand" aria-label="Ship" tabindex="-1"></button>
  </div>
</div>
```
