Kaapi UI
Back to Design System

Carousel

A flexible and accessible carousel component for displaying content in a sliding format. Built with Embla Carousel for smooth animations and touch support.

1. Basic Carousel

The simplest way to use the carousel with default controls and indicators.

Slide 1
Slide 2
Slide 3
import { Carousel } from "@/components/ui/carousel";

<Carousel
    items={[
      <div>Slide 1</div>,
      <div>Slide 2</div>,
      <div>Slide 3</div>,
    ]}
/>

2. Image Carousel

Perfect for showcasing product images or photo galleries.

Image 1
Image 2
Image 3
import { Carousel } from "@/components/ui/carousel";
import Image from "next/image";

<Carousel
    items={[
      <div key={1} className="w-full h-[400px] relative"><Image src="/img1.webp" alt="Image 1" fill className="object-cover" /></div>,
      <div key={2} className="w-full h-[400px] relative"><Image src="/img2.avif" alt="Image 2" fill className="object-cover" /></div>,
      <div key={3} className="w-full h-[400px] relative"><Image src="/img3.avif" alt="Image 3" fill className="object-cover" /></div>,
    ]}
    contentClassName="gap-2"
    itemClassName="overflow-hidden rounded-xl"
/>

3. Testimonial Carousel

Display customer testimonials with custom styling.

This product has completely transformed how we work. Highly recommend!

JD

John Doe

CEO, Company Inc.

Incredible experience from start to finish. The team was amazing!

JS

Jane Smith

Designer, Studio XYZ

Best investment we've made this year. Results speak for themselves.

MB

Mike Brown

Founder, Startup Labs

import { Carousel } from "@/components/ui/carousel";

<Carousel
  items={[
    <div className="p-8 bg-alpha-white rounded-lg">
      <p className="text-lg mb-4">"Amazing product!"</p>
      <div className="flex items-center gap-3">
        <img src="/avatar.jpg" className="w-12 h-12 rounded-full" />
        <div>
          <p className="font-semibold">John Doe</p>
          <p className="text-sm text-quaternary">CEO, Company</p>
        </div>
      </div>
    </div>,
    // More testimonials...
  ]}
  opts={{ loop: true }}
/>

4. Auto-play Carousel

Carousel without manual controls, ideal for banner rotations.

Summer Sale

Up to 50% off

New Arrivals

Check out our latest collection

Free Shipping

On orders over $50

import { Carousel } from "@/components/ui/carousel";

<Carousel
  items={[...]}
  showControls={false}
  opts={{ loop: true }}
/>

5. Advanced Custom Carousel

For complex use cases, use CarouselCustom for full control over layout and behavior.

Featured Products

Product 1

Product Name 1

Description of product

$29.99

Product 2

Product Name 2

Description of product

$59.98

Product 3

Product Name 3

Description of product

$89.97

Product 4

Product Name 4

Description of product

$119.96

import { CarouselCustom } from "@/components/ui/carousel";

<CarouselCustom.Root opts={{ align: "start", loop: true }}>
  <div className="flex justify-between items-center mb-4">
    <h3>Featured Products</h3>
    <div className="flex gap-2">
      <CarouselCustom.PrevTrigger>←</CarouselCustom.PrevTrigger>
      <CarouselCustom.NextTrigger>→</CarouselCustom.NextTrigger>
    </div>
  </div>
  
  <CarouselCustom.Content className="gap-4">
    <CarouselCustom.Item className="basis-1/3">
      {/* Your content */}
    </CarouselCustom.Item>
  </CarouselCustom.Content>
  
  <CarouselCustom.IndicatorGroup>
    {({ index }) => (
      <CarouselCustom.Indicator 
        key={index} 
        index={index} 
      />
    )}
  </CarouselCustom.IndicatorGroup>
</CarouselCustom.Root>

API Reference

Carousel Props (Simple API)

PropTypeDefaultDescription
itemsReactNode[]Array of slides to display in the carousel.
opts?CarouselOptionsEmbla Carousel options (loop, align, etc.).
orientation?"horizontal" | "vertical""horizontal"Direction of the carousel.
showControls?booleantrueShow previous/next navigation buttons.
showIndicators?booleantrueShow dot indicators for each slide.
controlsClassName?stringCustom classes for control buttons.
indicatorsClassName?stringCustom classes for indicators container.
itemClassName?stringCustom classes for each carousel item.
contentClassName?stringCustom classes for content container.

CarouselCustom Components

ComponentDescription
RootMain carousel wrapper with context provider.
ContentContainer for carousel items with overflow handling.
ItemIndividual slide wrapper.
PrevTriggerButton to navigate to previous slide.
NextTriggerButton to navigate to next slide.
IndicatorGroupContainer for slide indicators.
IndicatorIndividual dot indicator for each slide.

Common Options

Frequently used Embla Carousel options that you can pass to the opts prop.

OptionTypeDescription
loopbooleanEnable infinite looping.
align"start" | "center" | "end"Align slides to start, center, or end.
slidesToScrollnumberNumber of slides to scroll at once.
skipSnapsbooleanSkip snapping to slides.
dragFreebooleanEnable free-scroll dragging.

💡 Tip: For a complete list of options, visit the Embla Carousel documentation.