Carousel Component — Astro

Accessible carousel with previous/next controls and optional slide indicators

Carousel Component

An accessible carousel for sliding content. Includes previous/next buttons and optional dot indicators. Uses role="region" and aria-roledescription="carousel" for screen readers.

Add this component

Run the command below in your project directory. When prompted, select the component(s) you want. The CLI will copy the CSS and component files.

Choose your package manager — click a tab to select, then copy the command.

npm pnpm yarn bun

Props

  • id (string, optional) — Unique id for the carousel (auto-generated if omitted)
  • showIndicators (boolean, optional) — Show dot indicators (default: true)
  • label (string, optional) — Accessible label for the region (default: "Carousel")
  • class (string, optional) — Additional CSS classes

Slots

Place one or more elements with class carousel__slide as direct children. Each slide is shown one at a time.

Live Example

Carousel

Usage

Usage

Full example for each framework (Astro, Vanilla, Svelte, Vue, React). Switch framework via View as or by clicking a Usage tab—both stay in sync.

Astro Vanilla Svelte Vue React

Other frameworks: Vanilla · Svelte · Vue · React