Mushilu-San UI

Search components

PlaygroundStorybookGitHub
Data display

Carousel

A set of slides shown one at a time, with previous and next controls and dots.

Selector: mui-carousel

Import
import { Carousel, CarouselContent, CarouselItem, CarouselPrev, CarouselNext, CarouselDots } from '@mushilu-san/ui/data-display';
PreviewCode

Loading example…

Overview

Carousel shows one slide at a time from mui-carousel-content. active is a two-way index of the visible slide, loop wraps from the last slide to the first, and autoPlay advances every N milliseconds.

Previous, next and dot controls are optional parts. The region has aria-roledescription="carousel".

When to use

  • Featured items or a hero banner with a few slides.
  • A gallery where users flip through the same kind of content.

When not to use

  • Content the user must see in full. Auto-advancing slides are easy to miss.
  • Many items to scan. Use a grid. Use Grid instead.

Guidelines

Do

  • Keep auto-play off unless the content is decorative, or give users a pause control.
  • Give each slide a meaningful heading.

Don't

  • Do not put the only copy of important information in a carousel.

Accessibility

Roles and attributes

ElementRoleNotes
hostregionaria-roledescription="carousel" and a label (default "Carousel").
slidegrouparia-roledescription="slide".
dotstablistEach dot is aria-selected for the visible slide.

Keyboard

KeysAction
ArrowLeftArrowRightMove to the previous or next slide (reversed in RTL).
TabShiftTabMoves between the previous, next and dot controls.
  • Avoid auto-play for content users need to read. If you use it, give users a way to pause.

API

Selector: mui-carousel

NameTypeDefaultDescription
loopbooleanfalse Wraps from the last slide to the first and back. Default `false`. Accepts attribute presence, e.g. <… loop>.
autoPlaynumber0 Advances to the next slide every N milliseconds. `0` turns auto-play off. Default `0`.
labelstring'Carousel' Accessible name of the carousel region. Default `Carousel`.
NameTypeDefaultDescription
activenumber0 Index of the visible slide, starting at 0. Two-way bindable with `[(active)]`.

CSS parts

  • ::part(root)

CarouselContent

Selector: mui-carousel-content

CSS parts

  • ::part(content)

CarouselItem

Selector: mui-carousel-item

CSS parts

  • ::part(item)

CarouselPrev

Selector: button[muiCarouselPrev]

CSS parts

  • ::part(prev)

CarouselNext

Selector: button[muiCarouselNext]

CSS parts

  • ::part(next)

CarouselDots

Selector: mui-carousel-dots

CSS parts

  • ::part(dot)
  • ::part(dots)

Tokens

  • --mui-color-surface
  • --mui-color-border
  • --mui-color-primary
  • --mui-color-focus-ring
  • --mui-touch-target