Skip to content

Carousel

Touch-friendly content rotator with autoplay, indicators, keyboard navigation, and reduced-motion support.

Data Display·Available inReactVueAngular·View as Markdown

Preview

tsx

Switch the framework picker (top-right of the panel) to render the same demo live in React, Vue, or Angular — same class names, ARIA, and visual output across all three.

Installation

Sisyphos UI ships unified packages for React, Vue, and Angular. Pick the one that matches your stack — every framework exports the same component classes, ARIA semantics, and CSS tokens.

$ pnpm add @sisyphos-ui/react

Then import the bundled stylesheet once at app entry: import "@sisyphos-ui/react/styles.css";

Usage

Idiomatic usage in each supported framework
import { Carousel } from "@sisyphos-ui/react";

export const Slides = () => (
  <Carousel autoPlay>
    <img src="/a.jpg" alt="" />
    <img src="/b.jpg" alt="" />
    <img src="/c.jpg" alt="" />
  </Carousel>
);

Auto-play

Enable `autoPlay` and tune the pace with `autoPlayInterval`. Pauses on hover/focus.

tsx

No loop

`loop={false}` stops wrapping — arrows disable at the edges.

tsx

Dots only

Hide arrow controls with `showArrows={false}` for pure dot-driven navigation.

tsx

Controlled index

Drive the carousel from outside UI with `index` + `onIndexChange`.

tsx
Slide 1 of 3

API

PropTypeDefaultDescription
indexnumberControlled active slide index.
defaultIndexnumber0Initial slide index when uncontrolled.
onIndexChange(index: number) => voidCalled with the new index on every slide change.
autoPlaybooleanfalseAuto-advance every `autoPlayInterval` ms.
autoPlayIntervalnumber5000Time between auto-advances in ms.
loopbooleantrueWrap from the last slide back to the first; when off, arrows disable at the edges.
showArrowsbooleantrueRender previous / next arrow buttons (hidden with a single slide).
showDotsbooleantrueRender dot indicators below the viewport.
pauseOnHoverbooleantruePause autoplay on mouse enter or focus.
ariaLabelstring"carousel"Value applied to the container's `aria-roledescription`.

The full API including refs, ARIA attributes, and HTML passthroughs lives in the package README on npm.

Accessibility

Adheres to the Carousel WAI-ARIA design pattern.

  • The container is a focusable role="region" (tabIndex={0}) with aria-roledescription (default "carousel", overridable via ariaLabel).
  • Each slide is role="group" with aria-roledescription="slide" and an aria-label of "n of total"; off-screen slides are aria-hidden="true".
  • Dot indicators form a role="tablist" labelled "Slide selector"; each dot is a role="tab" with aria-selected and a "Go to slide n" label.
  • Arrow buttons carry "Previous slide" / "Next slide" aria-labels and disable at the edges when loop is off.
  • Autoplay pauses while the carousel is hovered or focused (pauseOnHover).

Keyboard interactions

KeyAction
ArrowRightAdvances to the next slide while the carousel region is focused.
ArrowLeftGoes back to the previous slide.
TabMoves focus from the region to the arrow buttons and dot indicators.
Need more?View on npm →
Was this page helpful?