Carousel

A slide deck with swipe, keyboard nav, autoplay, fractional slides-per-view and fade mode.

Slide one

Import#

import { Carousel } from "astralis-ui";
// Carousel.Track, .Slide, .Control, .Prev, .Next,
// .Indicators, .ProgressText, .AutoPlayTrigger

Anatomy#

The compound parts compose freely — put controls above, below, or skip them:

<Carousel loop>
  <Carousel.Track>
    <Carousel.Slide>…</Carousel.Slide>
  </Carousel.Track>
  <Carousel.Control>
    <Carousel.Prev />
    <Carousel.Indicators />
    <Carousel.Next />
  </Carousel.Control>
</Carousel>

Autoplay#

autoPlay advances on an interval and pauses on hover by default; AutoPlayTrigger gives users a play/pause control and ProgressText a screen-reader-friendly readout.

Aurora

1 / 0

Multiple slides per view#

Fractional slidesPerView peeks the next slide — the strongest "you can swipe this" cue there is.

1

2

Fade#

animation="fade" cross-fades in place instead of translating the track — better for hero imagery.

First slide

Props#

PropTypeDefaultDescription
index · defaultIndex · onIndexChangenumber · number · (index: number) => void— · 0 · —Controlled / initial slide, and the change callback.
slidesPerViewnumber1Visible slides; fractional values (1.5) peek the next slide.
slidesToScrollnumber1Slides advanced per step.
slideGapnumber0Pixel gap between slides.
loopbooleanfalseWraps from the last slide back to the first.
autoPlay · autoPlayInterval · pauseOnHoverboolean · number · booleanfalse · 3000 · trueAutomatic advancing, its cadence, and hover pause.
animation"slide" | "fade""slide"Translate the track, or cross-fade in place.
orientation"horizontal" | "vertical""horizontal"Slide axis; keyboard arrows follow it.
speed · easingnumber · string300 · "ease-out"Transition duration (ms) and CSS easing.
swipeable · draggablebooleantrue · falseTouch swipe and mouse drag gestures.
size"sm" | "md" | "lg""md"Control and indicator sizing.
colorScheme"brand" | "gray" | … (all 11 schemes)"brand"Active indicator and focus-ring hue.
beforeChange · afterChange(from, to) => void · (current) => voidTransition lifecycle hooks.

Parts#

PropTypeDefaultDescription
Carousel.Track / Carousel.SlidechildrenThe scroller and each slide (role=group with slide labels).
Carousel.Prev / Carousel.Nexticon?: ReactNodeStep buttons; default chevrons follow the orientation.
Carousel.Indicatorsvariant?: "dot" | "line" | "number""dot"One indicator per slide, rendered as an accessible tablist.
Carousel.ProgressTextformat?: (index, total) => ReactNode"1 / 3"Live-region progress readout.
Carousel.AutoPlayTriggerchildren?: (isPlaying) => ReactNodePlay/pause toggle for autoPlay.

Keyboard#

With focus anywhere inside the carousel:

KeyAction
/ Previous / next page (horizontal)
/ Previous / next page (vertical)

Accessibility#

  • The root is a region with aria-roledescription="carousel"; slides are labeled groups ("Slide 2 of 5").
  • Off-screen slides are aria-hidden and inert, so focus can't leak into them.
  • Indicators form a real tablist.