Rendered by GPUI’s web backend from the real component. Requires a browser with WebGPU.
CarouselState::new(labels, cx) retains a fixed ordered collection and selected
(leading) slide. Selection is bounded by default; .looping(true) permits wrapping.
.slides_per_view(n) or set_slides_per_view(n, window, cx) shows n
consecutive slides, like shadcn's fractional item basis. Each step moves by one
slide and the last view stays full, so snap_count() leading positions exist and
visible_range() names the mounted slides; looping wraps between the last full
view and the first. Carousel::new(id, &state, label) supplies a named focusable
region, and CarouselSlide::new(&state, index) mounts only slides in the current
view. The application retains slide data and supplies media, slide widths (for
example equal flex_1 slides in a row), content and indicator presentation.
CarouselControl::previous/next compose Button with boundary disabled behavior.
Left/Right act while the horizontal region itself holds focus, Up/Down for a
vertical region; Home/End select the first and last views. Slide descendants keep
their own keys. Configure axis and direction on Carousel; every slide uses that
same state for swipes. Direction is inherited by default. A pointer drag of 40
logical pixels snaps once per gesture, including a single move followed
immediately by release. Moving slides out of view, including by shrinking the
view, returns focus inside them to the carousel scope before unmounting; focus in
slides that stay visible and on external previous/next controls is kept. There is
no inertia, animated motion or free-scrolling between snaps.
set_autoplay(Some(interval), window, cx) advances one slide per interval and
wraps from the last view to the first; None or is_autoplaying() control and
report it. Rotation pauses while the pointer is over the carousel, focus is inside
it, the window is inactive, or reduced motion is on, and keyboard, swipe and
CarouselControl navigation stop it, like Embla's default autoplay plugin.
Application calls such as pagination select do not stop it. Render a visible
play/pause Button, as the catalogue does with "Play slideshow", so people can
stop rotation (WCAG 2.2.2).