datui
Color scheme

Data display

Gallery

A swipeable carousel of slides with snapping, bullets, arrows, looping and optional autoplay. Built on embla-carousel.

import { Gallery } from "datui";

Examples

Uncontrolled, with bullets and arrows.

slideIndex + onChange. Without onChange the gallery can't be dragged.

slideWidth with align="center" and looped.

autoplay advances every n ms and pauses on hover, focus, drag and with its pause button.

Accessibility

  • The root is a role="region" with aria-roledescription="carousel" and an aria-label (default "Gallery").
  • Each slide is a role="group" with aria-roledescription="slide" and a "n of m" label (slideLabel).
  • The root is focusable: Left/Right move one slide (flipped in RTL), Home/End jump to the first/last.
  • Prev/next arrows are labelled buttons (prevLabel, nextLabel) with aria-controls pointing at the slide viewport; they hide at the ends unless looped.
  • The slide viewport is aria-live="polite" while autoplay is not running, so manual changes are announced.
  • Autoplay pauses on mouse hover, keyboard focus inside and dragging, has a pause/play button, and is off under prefers-reduced-motion.
  • Bullets are decorative (aria-hidden); position is conveyed by slide labels.

API

Swipeable carousel built on embla. Each child is a slide. Follows the carousel pattern: a labelled region, slides as labelled groups, prev/next buttons, Left/Right/Home/End keys while the gallery is focused.

PropTypeDefaultDescription
align"center" | "start" | "end"startWhere the current slide sits in the viewport.
arrowSize"s" | "m"m
autoplaynumber0Advance every `autoplay` ms (0 = off). Pauses on hover, focus and drag; off under reduced motion.
bulletsfalse | "light" | "dark"falseDot indicators drawn over the slides.
classNamestring—
defaultSlideIndexnumber0
dragDisabledbooleanfalseDisable pointer/touch dragging. Arrows and keyboard keep working.
loopedbooleanfalseWrap around from the last slide to the first.
nextLabelstringNext slide
onChange((index: number) => void)—
onDragEnd(() => void)—
onDragStart(() => void)—
pauseLabelstringPause slideshowPause button label while autoplay runs.
playLabelstringPlay slideshowPlay button label while autoplay is paused.
prevLabelstringPrevious slide
roleDescriptionstringcarousel
showArrowsboolean | "always"false`true` shows prev/next buttons on devices with a fine pointer, `"always"` on every device.
slideIndexnumber—Controlled index of the current slide. Without `onChange` the gallery can't be dragged.
slideLabel((index: number, total: number) => string)(index: number, total: number) => `${index + 1} of ${total}`Accessible name of each slide.
slideRoleDescriptionstringslide
slideWidthstring | number100%Width of every slide. `"custom"` leaves sizing to the slides themselves.