# Carousel

> Steps through slides with buttons and indicators.

- Category: [Navigation](https://tarve.dev/docs.md#navigation)
- Import: `import { Carousel } from "@tarve/core";`
- Props type: `CarouselProps`
- Source: [packages/core/src/advanced-controls.ts:26](https://github.com/omarcosr/tarve/blob/main/packages/core/src/advanced-controls.ts#L26)

## Usage

```tsx title="Carousel.tsx"
import { Carousel, Column, Text } from "@tarve/core";

let index = 0;

const slide = (title: string, background: string) => (
  <Column align="center" justify="center" style={{ width: 280, height: 160, radius: 12, background }}>
    <Text size={28} weight={700}>{title}</Text>
  </Column>
);

<Carousel
  index={index}
  loop
  items={[
    { value: "one", content: slide("One", "#4c1d95") },
    { value: "two", content: slide("Two", "#155e75") },
    { value: "three", content: slide("Three", "#9a3412") },
  ]}
  onIndexChange={(next) => {
    index = next;
  }}
/>
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `index` (required) | `number` | — |  |
| `items` (required) | `readonly CarouselItem[]` | — |  |
| `loop` | `boolean` | `false` |  |
| `nextLabel` | `string` | `"Next slide"` |  |
| `onIndexChange` | `(index: number) => void` | — |  |
| `previousLabel` | `string` | `"Previous slide"` |  |
| `showIndicators` | `boolean` | `true` |  |

## Common props

Shared by every component (descriptions: https://tarve.dev/docs.md#common-props): `children`, `class`, `className`, `highlight`, `id`, `key`, `motionFrom`, `onHighlight`, `onPaste`, `onPointerLeave`, `onPointerMove`, `onSize`, `onTransitionEnd`, `rovingGroup`, `style`.

## Types

```ts title="CarouselItem"
interface CarouselItem {
  value: string;
  content: Child;
  label?: string;
}
```

Previous: [Sidebar](https://tarve.dev/docs/components/Sidebar.md) · Next: [Card](https://tarve.dev/docs/components/Card.md)

---

Tarve v0.13.8 · HTML version: https://tarve.dev/docs/components/Carousel · Index for agents: https://tarve.dev/llms.txt
