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
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
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