Skip to main content

Overview

The Carousel component provides a fully-featured image and content slider with support for automatic sliding, navigation buttons, indicators, captions, and custom rendering. It’s built with composition in mind and offers fine-grained control over behavior and appearance.

Use Cases

  • Image galleries and slideshows
  • Product showcases and feature highlights
  • Testimonial sliders
  • Hero sections with rotating content
  • Portfolio presentations

Installation

The Carousel component is included with the UI package:

Basic Usage

Component Parts

The root container that manages carousel state and behavior.
Props:
  • images - Array of image URLs or objects with image data (required)
  • hasAutoSlide - Enable automatic sliding (default: false)
  • autoSlideInterval - Interval in milliseconds for auto-slide (default: 3000)
  • shouldPauseOnHover - Pause auto-slide on hover (default: false)
  • onSlideBtnClick - Callback when navigation buttons are clicked
  • classNames - Custom classes for base and scrollContainer
  • as - Change rendered element (default: "div")
Container for carousel items with slide transition animations.
Props:
  • children - Render function receiving { image, index, array } or static content
  • each - Optional array to override images from Root
  • className - Custom CSS classes
Individual carousel item wrapper.
Navigation controls container with previous/next buttons.
Props:
  • classNames - Custom classes for controls, icon container, and default icon
  • icon - Custom navigation icons (see Icon Patterns below)
Individual navigation button (used internally by Controls).
Container for slide indicators.
Individual slide indicator dot/button.
Overlay caption for carousel items.

Examples

Custom Navigation Icons

Single Icon Pattern

You can also use a single icon that rotates for the next button:
The carousel supports flexible icon configuration:

Styling

All Carousel parts include data attributes for styling:

Custom Styling Example

Accessibility

  • Navigation buttons include type="button" and proper ARIA labels
  • Indicators are clickable buttons that navigate to specific slides
  • Keyboard navigation supported through button elements
  • Auto-slide pauses on hover when shouldPauseOnHover is enabled
The carousel uses CSS transforms for smooth transitions between slides.
For optimal performance with many slides, consider lazy-loading images outside the current viewport.

API Reference

For detailed prop types and advanced usage, see the Carousel API Reference.