Carousel
A carousel with motion and swipe built using Embla.
Installation#
pnpm dlx shadcn@latest add @davinciui/carouselUsage#
Composition#
Use the following composition to build a Carousel:
Carousel
├── CarouselContent
│ └── CarouselItem
├── CarouselPrevious
├── CarouselNext
├── CarouselDots
├── CarouselCounter
├── CarouselProgress
└── CarouselPlayButtonAPI Reference#
| Prop | Type | Default |
|---|---|---|
CarouselRoot container. Wraps all carousel parts. | Component | — |
CarouselContentScrollable container that holds CarouselItem elements. | Component | — |
CarouselItemSingle slide. Use basis-* utilities to control visible count. | Component | — |
CarouselPrevious / CarouselNextNavigation buttons. Disabled automatically at bounds. | Component | — |
CarouselDotsAccessible pill pagination (tablist). 44px touch targets, aria-selected, auto-expanding active dot. | Component | — |
CarouselCounterNumbers pagination with aria-live announcement (Slide X of Y). | Component | — |
CarouselProgressLinear progressbar pagination with role=progressbar and aria-valuenow. | Component | — |
CarouselPlayButtonVisible play/pause toggle for autoplay. Renders only when autoplay is enabled. | Component | — |
autoplayAuto-advance slides. Off by default; disabled under prefers-reduced-motion. | boolean | false |
autoplayIntervalDelay between slides in ms. Use >= 5000 image-only, >= 7000 text-heavy. | number | 5000 |
pauseOnHover / pauseOnFocusPause autoplay while hovered or focused (WCAG requirement). | boolean | true |
ariaLabelAccessible label for the carousel region. Slides auto-label as Slide X of Y. | string | "Carousel" |
orientationAxis of the carousel. Sets Embla axis to x or y. | "horizontal" | "vertical" | "horizontal" |
optsEmbla options — e.g. { align: 'start', loop: true, direction: 'rtl' | 'ltr' }. | CarouselOptions | — |
pluginsEmbla plugins — e.g. Autoplay({ delay: 2000 }). | EmblaPluginType[] | — |
setApiReceives the Embla API for imperative control (dots, current index, events). | (api: CarouselApi) => void | — |
classNameAdditional CSS classes. | string | — |
Accessibility#
The root is a labeled carousel region that captures left and right arrows, slides are groups labeled Slide X of Y, and a polite live region announces changes. Dots use tablist semantics, though vertical carousels still respond only to left and right.
Motion#
Embla animates slide position from its opts, while dot and progress indicators transition width over 300ms. Autoplay is disabled when prefers-reduced-motion matches at mount, but that check does not update on change.
Customization#
Every carousel part renders a data-slot hook, so controls and slides can be restyled without changing the component. Pass Embla options through the opts prop and use className on each part for layout.
Styling slots
[data-slot="carousel"][data-slot="carousel-content"][data-slot="carousel-item"][data-slot="carousel-previous"][data-slot="carousel-next"][data-slot="carousel-dots"][data-slot="carousel-counter"][data-slot="carousel-progress"][data-slot="carousel-play-button"]View source
Keep in mind
Need a custom component?
I build bespoke UI components & websites tailored to your brand.

