Skip to content

Design system

Documentation

DesignComponents / Carousel

Components / Carousel

Stable

Carousel

Browse one slide at a time with manual controls and optional reduced-motion-aware rotation.

On this page

Examples

Usage

import { Carousel } from "@phuctech/ui/components/carousel";

<Carousel label="Project summary" slides={slides} />

Rotation

Manual navigation is the default. When autoPlay is enabled, the component provides a pause/resume control and stops rotation while a pointer hovers, keyboard focus is inside, or reduced motion is enabled. Delay is clamped to two through thirty seconds. Use a carousel only when the hidden slides are supplemental; important content should remain visible without rotation.

API

Component API
PropTypeDefaultDescriptionConstraints
label / slidesstring / readonly CarouselSlide[]requiredAccessible carousel region and ordered slide data.Each slide needs a stable ID, title, and content.
index / defaultIndexnumber0Controlled slide or initial index.Out-of-range values are clamped to the available slides.
onIndexChange(index: number) => void—Receives the next slide index after navigation.The feature owns any synchronization with other views.
autoPlaybooleanfalseEnables optional automatic rotation.Rotation pauses for reduced motion, pointer hover, and keyboard focus.
intervalMsnumber5000Automatic rotation interval.Clamped to 2000–30000 milliseconds.

Accessibility

The region and current slide have descriptive names. Previous/next buttons are labeled, left/right arrows navigate when focus is inside, and live announcements are disabled only while automatic rotation is active. A visible pause/resume button remains available.

  • Tabs keeps all section labels available for direct navigation.
  • Image provides a responsive image with optional preview.