Skip to content

Carousel

Swipeable, paginated slide container built on Embla — for hero sections, galleries, and feature tours.

  • stable
  • since v0.1.0
  • 5.0 kB
  • data-display
  • carousel
  • embla

Slides expose roving focus; previous/next controls are real buttons with aria-labels; ArrowLeft/Right (or Up/Down) navigates slides.

Preview
Open
tsx

Pass a number to show several slides at once. Use a responsive object (base, sm, md, lg, xl) for breakpoint-aware gallery layouts.

Preview
Open
tsx

Set loop to wrap from the last slide back to the first. The previous/next buttons stay enabled at the bounds when looping is active.

Preview
Open
tsx

Pass orientation="vertical" for a stacked carousel; ArrowUp / ArrowDown navigate between slides.

Preview
Open
tsx
PropTypeDefaultDescription
slidesPerView
number|ResponsiveSlides
1
How many slides fit in the viewport. `1` is a classic full-bleed carousel; larger values create a "peek" layout for gallery/card decks. Accepts a number or a responsive `{ base, sm, md, lg, xl }` object.
orientation
"horizontal"|"vertical"
horizontal
Scroll axis. `horizontal` maps to Embla's `x` axis, `vertical` to `y`.
loop
boolean
false
Loop back to the first slide after the last (and vice versa).
align
"start"|"center"|"end"
start
Where each slide snaps inside the viewport.
slidesToScroll
number|"auto"
1
How many slides advance per next/prev. `auto` snaps a full viewport's worth at a time.
draggable
boolean
true
Enable drag-to-scroll via pointer/touch.
options
Partial<OptionsType>
Full Embla options bag — overrides any of the convenience props above.
plugins
CreatePluginType<LoosePluginType, {}>[]
Embla plugins (autoplay, auto-scroll, class-name toggle, etc.).
setApi
((api: EmblaCarouselType) => void)
Fires once Embla initialises with the live API; use to drive external UI.
onSelect
((index: number) => void)
Fires whenever the selected slide index changes (initial + on user/programmatic scroll).
children
ReactNode
Carousel parts ({@link CarouselViewport}, controls, dots, …).
  • The root region exposes aria-roledescription="carousel".
  • Each CarouselSlide carries role="group" + aria-roledescription="slide".
  • CarouselPrevious / CarouselNext are real <button> elements with descriptive aria-labels and are disabled at the bounds when loop is off.
  • Pagination dots use role="tablist" / role="tab" and reflect the active slide via aria-selected.
  • Arrow keys on the root scroll between slides — ArrowLeft / ArrowRight horizontally, ArrowUp / ArrowDown vertically.
  • Pass slidesPerView={{ base: 1, sm: 2, lg: 3 }} for responsive multi-slide layouts.
  • Use the plugins prop to add Embla extensions like embla-carousel-autoplay.
  • Pass a custom icon to CarouselPrevious / CarouselNext to replace the default chevrons.
  • Use setApi to capture the Embla API for external “go to slide N” buttons or scroll-progress UI.