Carousel

Ready

Part of Data Display collection

Interactive Preview

Image carousel with auto-play, navigation arrows, and dot indicators

Mountain Adventure

Mountain Adventure

Explore the breathtaking peaks and valleys

Beach Paradise

Beach Paradise

Relax on pristine shores under the sun

Forest Retreat

Forest Retreat

Find peace in the heart of nature

Custom Content

Carousel with custom React components instead of images

Welcome

Slide with custom content

Features

Auto-play, navigation, and more

Get Started

Easy to integrate and customize

Features

  • Image slides with title and description overlays
  • Custom React content for any slide
  • Auto-play with configurable interval
  • Navigation arrows (show on hover)
  • Dot indicators for slide position
  • Smooth transitions with automatic looping
  • Pause auto-play on hover

Installation

Import the Carousel component and CarouselItem type:

import { Carousel, type CarouselItem } from '@/components/ui/carousel'

Usage Examples

Basic Image Carousel

const slides: CarouselItem[] = [
  {
    image: '/image1.jpg',
    title: 'Slide 1',
    description: 'First slide description'
  },
  {
    image: '/image2.jpg',
    title: 'Slide 2',
    description: 'Second slide description'
  }
]

<Carousel items={slides} />

With Auto-Play

<Carousel
  items={slides}
  autoPlay
  autoPlayInterval={3000}
/>

Custom Content

const slides: CarouselItem[] = [
  {
    content: <div>Custom React content here</div>
  },
  {
    content: <MyComponent />
  }
]

<Carousel items={slides} />

Without Controls

<Carousel
  items={slides}
  showArrows={false}
  showDots={false}
/>

API Reference

Carousel Props

PropTypeDefaultDescription
itemsCarouselItem[]requiredArray of slides to display
autoPlaybooleanfalseEnable automatic slide transitions
autoPlayIntervalnumber5000Interval in milliseconds between slides
showDotsbooleantrueShow dot indicators
showArrowsbooleantrueShow navigation arrows
classNamestring-Additional CSS classes

CarouselItem Type

PropertyTypeRequiredDescription
imagestringNoImage URL for the slide
titlestringNoTitle overlay text
descriptionstringNoDescription overlay text
contentReact.ReactNodeNoCustom React content (alternative to image)