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
Basic
Uncontrolled, with bullets and arrows.
Slide 1
Slide 2
Slide 3
Slide 4
Controlled
slideIndex + onChange. Without onChange the gallery can't be dragged.
Welcome
Pick a plan
Invite your team
Step 1 of 3
Custom slide width and looping
slideWidth with align="center" and looped.
Product 1
Product 2
Product 3
Product 4
Product 5
Product 6
Autoplay
autoplay advances every n ms and pauses on hover, focus, drag and with its pause button.
New release
Webinar on Friday
Join the beta
Accessibility
- The root is a
role="region"witharia-roledescription="carousel"and anaria-label(default "Gallery"). - Each slide is a
role="group"witharia-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) witharia-controlspointing at the slide viewport; they hide at the ends unlesslooped. - 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
Gallery
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.
| Prop | Type | Default | Description |
|---|---|---|---|
| align | "center" | "start" | "end" | start | Where the current slide sits in the viewport. |
| arrowSize | "s" | "m" | m | |
| autoplay | number | 0 | Advance every `autoplay` ms (0 = off). Pauses on hover, focus and drag; off under reduced motion. |
| bullets | false | "light" | "dark" | false | Dot indicators drawn over the slides. |
| className | string | — | |
| defaultSlideIndex | number | 0 | |
| dragDisabled | boolean | false | Disable pointer/touch dragging. Arrows and keyboard keep working. |
| looped | boolean | false | Wrap around from the last slide to the first. |
| nextLabel | string | Next slide | |
| onChange | ((index: number) => void) | — | |
| onDragEnd | (() => void) | — | |
| onDragStart | (() => void) | — | |
| pauseLabel | string | Pause slideshow | Pause button label while autoplay runs. |
| playLabel | string | Play slideshow | Play button label while autoplay is paused. |
| prevLabel | string | Previous slide | |
| roleDescription | string | carousel | |
| showArrows | boolean | "always" | false | `true` shows prev/next buttons on devices with a fine pointer, `"always"` on every device. |
| slideIndex | number | — | 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. |
| slideRoleDescription | string | slide | |
| slideWidth | string | number | 100% | Width of every slide. `"custom"` leaves sizing to the slides themselves. |