UI.MD

Carousel

A carousel with motion and swipe, built on Embla. Supports horizontal and vertical orientation, keyboard navigation, and autoplay plugins.

Installation

$
npx shadcn@latest add https://ui.mattdowney.com/r/carousel.json

Usage

import {
  Carousel, CarouselContent, CarouselItem, CarouselPrevious, CarouselNext,
} from "@/components/ui/carousel"

Examples

Default

Aurora over a mountain ridge
Rocky coastline at dusk
Sunlit desert dunes
Misty pine forest
Boats in a quiet harbor
City skyline at night

Multiple items

Aurora over a mountain ridge
Rocky coastline at dusk
Sunlit desert dunes
Misty pine forest
Boats in a quiet harbor
City skyline at night

API Reference

PropTypeDefaultDescription
optsCarouselOptions-Embla options object (loop, align, duration, ...). The kit defaults duration to 14, an Embla physics value (~10 to 60), not milliseconds.
pluginsCarouselPlugin-Embla plugins array, e.g. autoplay from embla-carousel-autoplay.
orientation"horizontal" | "vertical""horizontal"Scroll axis. Vertical stacks slides and moves the arrows above and below the viewport.
setApi(api: CarouselApi) => void-Receives the Embla API instance for programmatic control (scrollTo, selectedScrollSnap, event listeners).