Carousel
React SDK guidance for Carousel.
Exact exports, props, slots, hooks, and runtime behavior belong to SDK package reference. Examples are guidance unless explicitly marked copy-paste-safe.
Review component intent and composition guidance before wiring this component into an app. Then use the live playground to confirm the rendered behavior.
Playground
- Import path:
@enadhq/enad-react-sdk/client/ui-resolver. - Live playground: /components/base-ui/carousel.
When to use it
Use Carousel when content should scroll horizontally with swipe and arrow controls. It fits product image galleries, recommendation rails, testimonial sliders, editorial highlights, and any horizontal browsing pattern where showing one or a few items at a time is more engaging than a full grid.
If the content should all be visible at once (like a responsive product grid), do not wrap it in a carousel. Carousels work best when the hidden content builds anticipation or when horizontal space is limited.
Slot strategy
Carousel is built on Embla Carousel with four visible pieces:
Carouselis the root container. It acceptsoptsfor Embla configuration (alignment, loop, drag behavior),orientationfor horizontal or vertical scrolling, andwheelAxisto control scroll/trackpad behavior.CarouselContentis the scrollable track that holds the slides.CarouselItemwraps each slide. Control how many slides are visible at once withbasis-*classes (e.g.basis-1/2for two-up,basis-1/3for three-up).CarouselPreviousandCarouselNextare arrow buttons positioned at the edges of the carousel.
Slide widths via basis classes
The carousel does not have a built-in "slides per view" prop. Instead, set the width on each
CarouselItemwith Tailwind basis utilities. Usebasis-fullfor one slide at a time,basis-1/2for two, or responsive variants likebasis-1/2 md:basis-1/3to adapt to viewport width.
Behavior and theming guidance
The carousel supports touch swipe, mouse drag, and keyboard navigation out of the box. Arrow buttons disable automatically when the carousel reaches the first or last slide (unless loop: true is set in opts).
Use wheelAxis to control scroll behavior. The default "vertical" lets the page scroll normally on vertical swipes. Set "horizontal" to enable horizontal trackpad swiping, or "both" to capture vertical scroll for the carousel (use sparingly, as it can interfere with page scrolling).
Pass Embla options through the opts prop for advanced behavior like align: "start" (left-align slides instead of centering), loop: true (infinite cycling), or dragFree: true (momentum-based scrolling without snap points).
For product galleries where you need programmatic control (jump to a specific slide, listen to scroll events), use the setApi callback to capture the Embla API instance.
Contract scope
- Use SDK package reference for exact props, exports, slots, hooks, and runtime behavior.
- Public import:
@enadhq/enad-react-sdk/client/ui-resolver. - Playground route: /sandbox?component=Carousel.
- Copy/paste scope: guidance-only. Treat examples as guidance until checked against SDK package reference.