docs/components/carousel
Sections
Components
Utilities
Forms
Hooks
Copy Markdown
Lets users cycle through a series of items.
PreviewCode
1
2
3
4
5
6
7
8
CLIManual
pnpmbunnpmyarn
pnpm dlx shadcn@latest add @shark/carousel
Carousel
├── CarouselContent
│ └── CarouselItem
├── CarouselControl
│ ├── CarouselPrevious
│ └── CarouselNext
└── CarouselIndicatorGroup
└── CarouselIndicator
import {
Carousel,
CarouselControl,
CarouselItem,
CarouselContent,
CarouselIndicator,
CarouselIndicatorGroup,
CarouselNext,
CarouselPrevious,
} from "@/components/ui/carousel";
<Carousel>
<CarouselControl>
<CarouselPrevious>Previous</CarouselPrevious>
<CarouselNext>Next</CarouselNext>
</CarouselControl>
<CarouselContent>
<CarouselItem />
<CarouselItem />
</CarouselContent>
</Carousel>
PreviewCode
PreviewCode
Render each thumbnail inside CarouselIndicator to create a visual preview of each slide.
PreviewCode
PreviewCode
Use autoplay props on Carousel to make the carousel play automatically.
PreviewCode
1
2
3
4
5
6
7
8
Use loop prop to make the carousel loop.
PreviewCode
1
2
3
4
Use page and onPageChange props to control the carousel state programmatically.
PreviewCode
1
2
3
4
5
6
7
8
Current page: 1 of 5
Display multiple slides simultaneously by setting the slidesPerPage prop on Carousel.
PreviewCode
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Control the gap between slides using the spacing prop on Carousel.
PreviewCode
1
2
3
4
5
6
7
8
To allow mouse drag, set the allowMouseDrag prop on Carousel.
PreviewCode
1
2
3
4
5
6
7
8
Root component. Manages slide state and navigation.
| Prop | Type | Default |
|---|---|---|
slideCount | number | required |
allowMouseDrag | boolean | false |
autoplay | `boolean | { delay: number }` |
defaultPage | number | 0 |
loop | boolean | false |
orientation | `"horizontal" | "vertical"` |
page | number | - |
slidesPerPage | number | 1 |
slidesPerMove | `number | 'auto'` |
spacing | string | "16px" |
padding | number | 0 |
className | string | - |
Wraps all slides. Handles layout and transitions.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | false |
Wraps a single slide.
| Prop | Type | Default |
|---|---|---|
index | number | required |
snapAlign | `"start" | "center" |
className | string | - |
asChild | boolean | false |
Holds prev/next navigation buttons.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | false |
Goes to the previous slide.
| Prop | Type | Default |
|---|---|---|
className | string | - |
Goes to the next slide.
| Prop | Type | Default |
|---|---|---|
className | string | - |
Holds slide indicator dots or pills.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | false |
Indicator for a slide. Click to jump to that slide.
| Prop | Type | Default |
|---|---|---|
index | number | required |
readOnly | boolean | false |
className | string | - |
asChild | boolean | false |
For a complete list of props, see the Ark UI documentation.
[
Previous page
Card ](/docs/components/card)[
Next page
Chart ](/docs/components/chart)
On This Page
InstallationAnatomyUsageOrientationHorizontalVerticalThumbnail IndicatorsHorizontalVerticalExamplesAutoplayLoopControlledSlides Per PageSpacingMouse DragAPI ReferenceCarouselCarouselContentCarouselItemCarouselControlCarouselPreviousCarouselNextCarouselIndicatorGroupCarouselIndicator