A carousel component with motion and swipe capabilities for cycling through elements.
import {
Carousel,
CarouselContent,
CarouselItem,
CarouselNext,
CarouselPrevious,
} from "@/components/ui/carousel"
export function CarouselDemo() {
return (
<Carousel className="w-full max-w-xs">
<CarouselContent>
{Array.from({ length: 5 }).map((_, index) => (
<CarouselItem key={index}>
<div className="p-1">
<div className="flex aspect-square items-center justify-center p-6 text-2xl font-semibold">
{index + 1}
</div>
</div>
</CarouselItem>
))}
</CarouselContent>
<CarouselPrevious />
<CarouselNext />
</Carousel>
)
}| Prop | Type | Default | Description |
|---|---|---|---|
| opts | CarouselOptions | - | Options for the carousel. |
| orientation | horizontal | vertical | horizontal | The orientation of the carousel. |
| setApi | function | - | A function that receives the carousel API object. |
| plugins | CarouselPlugin | - | Plugins for the carousel. |