0.1.0-rc.2

Carousel

Carousels cycle through a set of panels (hero images, feature highlights, or onboarding steps) while keeping one slide in focus.

Try it

Usage

Place RuiCarouselSlide children inside RuiCarousel. Enable autoplay only when motion is not distracting and can be paused.

import { RuiCarousel, RuiCarouselSlide, RuiCarouselPrev, RuiCarouselNext } from '@ecopages/radiant-ui/carousel';
 
<RuiCarousel index={0} transition="slide" showIndicators>
  <RuiCarouselSlide>First panel</RuiCarouselSlide>
  <RuiCarouselSlide>Second panel</RuiCarouselSlide>
  <RuiCarouselPrev />
  <RuiCarouselNext />
</RuiCarousel>

Use autoplay sparingly

Autoplaying carousels can disorient users and violate reduced-motion preferences. Prefer manual controls and expose showRotationControl when autoplay is on.

Pick a transition

slide moves content horizontally. fade cross-fades panels. none swaps instantly and is best when motion would be gratuitous.

Theming

Carousel maps to semantic surface and border roles, never Tailwind palette steps:

PartCSS roles
Viewport (rui-carousel__viewport)surface, border, radius-container
Indicatorsbackground, border
Active indicatorprimary
Overlay chromesurface, border, shadow-sm (blurred pills)
Focusfocus-ring
Geometry--space-inline, --space-stack, --space-inset

Override at the theme layer, not in component CSS.

API

RuiCarousel is a custom element (<rui-carousel>) that owns slide state, autoplay, transitions, and control chrome. The RuiCarouselSlide and control helpers compose the surface.

Attributes

AttributeTypeDefaultDescription
labelstringCarouselAccessible name for the carousel region.
indexnumber0Active slide index.
autoplaybooleanfalseAdvance automatically.
intervalnumber4000Autoplay interval in ms.
transitionnone · slide · fadenoneSlide swap animation.
controls-varianttoolbar · overlaytoolbarChrome layout.
show-indicatorsbooleanfalseRender tabbed indicator pickers.
show-rotation-controlbooleanfalseRender play/pause control.
loopbooleantrueAllow looping past the last slide.
wrapbooleantrueKeep controls enabled at the ends.
slide-countnumber0Authored slide count for render-time control state.

Slots

SlotDescription
(default)Slides, each marked data-slide (see RuiCarouselSlide).
prevCustom previous control (data-carousel-action="prev").
nextCustom next control (data-carousel-action="next").
rotationCustom play/pause control (data-carousel-action="rotation").

View helpers

ComponentRendersNotes
RuiCarouselSlideSlide panelAdd id; host applies group / tabpanel roles.
RuiCarouselPrevPrev buttonSlotted into prev.
RuiCarouselNextNext buttonSlotted into next.
RuiCarouselRotationPlay/pause buttonSlotted into rotation.

CSS classes

Public BEM classes (documented via @cssclass on the element and view helpers):

ClassDescription
.rui-carouselRoot region (aria-roledescription="carousel").
.rui-carousel--noneNo animation between slides.
.rui-carousel--slideHorizontal slide transition.
.rui-carousel--fadeCross-fade transition.
.rui-carousel--controls-toolbarControls below the viewport.
.rui-carousel--controls-overlayControls overlaid on the viewport.
.rui-carousel__stageViewport wrapper.
.rui-carousel__viewportOverflow-hidden slide window.
.rui-carousel__trackSlide track.
.rui-carousel__slideSlide surface (RuiCarouselSlide).
.rui-carousel__footerControls row below the viewport.
.rui-carousel__toolbarToolbar grid.
.rui-carousel__toolbar-rotationRotation control cell.
.rui-carousel__toolbar-centerIndicators cell.
.rui-carousel__toolbar-side--startPrev control cell.
.rui-carousel__toolbar-side--endNext control cell.
.rui-carousel__navPrev/next button (RuiCarouselPrev / RuiCarouselNext).
.rui-carousel__nav--overlayCircular on-slide chrome.
.rui-carousel__nav--toolbarToolbar chrome (default).
.rui-carousel__nav-labelIcon + label row (toolbar variant).
.rui-carousel__nav-iconDecorative chevron glyph.
.rui-carousel__rotationRotation toggle button (RuiCarouselRotation).
.rui-carousel__rotation--overlayOverlay pill chrome.
.rui-carousel__overlay-chromeAbsolute overlay layer over the viewport.
.rui-carousel__overlay-rotationRotation control overlay position.
.rui-carousel__controls--overlayPrev/next overlay row.
.rui-carousel__indicatorsIndicator tablist.
.rui-carousel__indicators--overlayOverlay pill indicator tablist.
.rui-carousel__indicatorIndicator button (role="tab").

Theme roles

PartCSS variables consumed
Viewport--surface, --border, --radius-container
Indicators--background, --border
Active indicator--primary
Overlay chrome--surface, --border, --shadow-control
Focus--focus-ring
Geometry--space-inline, --space-stack, --space-inset

Accessibility

  • Provide a descriptive label so screen readers identify the carousel region.
  • Prev/next controls must be keyboard reachable and expose their purpose in the accessible name.
  • Respect prefers-reduced-motion and avoid autoplay when users request reduced motion.