Carousel
Embla-backed carousel that shares scroll state and controls with its parts (CarouselContent, CarouselPrevious/Next, CarouselDots) via context — they must render inside it.
Usage
import { Carousel, CarouselApi, CarouselContent, CarouselContentProps, CarouselDots, CarouselDotsProps, CarouselItem, CarouselItemProps, CarouselNext, CarouselNextProps, CarouselPrevious, CarouselPreviousProps, CarouselProps, useCarousel } from "@desk/ui/components/carousel";Best practices
Render
CarouselContent/CarouselItem/CarouselPrevious/CarouselNext/CarouselDotsonly insideCarousel— they read scroll state from context and throw ("must be used within a Carousel") outside it.Set
slidesToShowto show multiple items at once (it drives each item'sflex-basis); don't fake a multi-item view with CSS widths onCarouselItem.Tune scroll behaviour via
opts(Embla options likeloop/align) and enablewheelScroll/freeScrolldeliberately — free-scroll drops snap points, so passslideCountif the dots miscount.Give a descriptive
aria-labelwhen the region isn't self-evidently "Carousel" (e.g."Product images").
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| aria-label | string | "Carousel" | Accessible name for the carousel region. |
| children | import("react").ReactNode | ||
| className | string | ||
| freeScroll | boolean | Enable free-scroll mode without snap points (useful for mobile galleries) | |
| opts | Partial<import("embla-carousel/esm/components/Options").OptionsType> | undefined | Embla options passed through to the underlying carousel. | |
| orientation | Orientation | "horizontal" | Scroll axis. |
| plugins | import("embla-carousel").CreatePluginType<import("embla-carousel/esm/components/Plugins").LoosePluginType, {}>[] | undefined | Embla plugins passed through to the underlying carousel. | |
| slideCount | number | Explicit slide count for dots - use when Embla miscounts due to custom slide sizing | |
| slidesToShow | number | 1 | Slides visible at once; drives each item's flex-basis. |
| wheelScroll | boolean | Enable mousewheel/trackpad scroll navigation (default: false) |
Also exports
- type
CarouselApi - component
CarouselContent - type
CarouselContentProps - component
CarouselDots - type
CarouselDotsProps - component
CarouselItem - type
CarouselItemProps - component
CarouselNext - type
CarouselNextProps - component
CarouselPrevious - type
CarouselPreviousProps - interface
CarouselProps - const
useCarousel