Install component
import * as React from "react" import { Card, CardContent } from "@/components/ui/card" import { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, } from "@/components/ui/carousel" function CarouselDemo() { return ( <Carousel className="w-full max-w-xs"> <CarouselContent> {Array.from({ length: 5 }).map((_, index) => ( <CarouselItem key={index}> <div className="p-1"> <Card> <CardContent className="flex aspect-square items-center justify-center p-6"> <span className="text-4xl font-semibold">{index + 1}</span> </CardContent> </Card> </div> </CarouselItem> ))} </CarouselContent> <CarouselPrevious /> <CarouselNext /> </Carousel> ) } function CarouselSize() { return ( <Carousel opts={{ align: "start", }} className="w-full max-w-sm" > <CarouselContent> {Array.from({ length: 5 }).map((_, index) => ( <CarouselItem key={index} className="md:basis-1/2 lg:basis-1/3"> <div className="p-1"> <Card> <CardContent className="flex aspect-square items-center justify-center p-6"> <span className="text-3xl font-semibold">{index + 1}</span> </CardContent> </Card> </div> </CarouselItem> ))} </CarouselContent> <CarouselPrevious /> <CarouselNext /> </Carousel> ) } function CarouselSpacing() { return ( <Carousel className="w-full max-w-sm"> <CarouselContent className="-ml-1"> {Array.from({ length: 5 }).map((_, index) => ( <CarouselItem key={index} className="pl-1 md:basis-1/2 lg:basis-1/3"> <div className="p-1"> <Card> <CardContent className="flex aspect-square items-center justify-center p-6"> <span className="text-2xl font-semibold">{index + 1}</span> </CardContent> </Card> </div> </CarouselItem> ))} </CarouselContent> <CarouselPrevious /> <CarouselNext /> </Carousel> ) } function CarouselOrientation() { return ( <Carousel opts={{ align: "start", }} orientation="vertical" className="w-full max-w-xs" > <CarouselContent className="-mt-1 h-[200px]"> {Array.from({ length: 5 }).map((_, index) => ( <CarouselItem key={index} className="pt-1 md:basis-1/2"> <div className="p-1"> <Card> <CardContent className="flex items-center justify-center p-6"> <span className="text-3xl font-semibold">{index + 1}</span> </CardContent> </Card> </div> </CarouselItem> ))} </CarouselContent> <CarouselPrevious /> <CarouselNext /> </Carousel> ) } export default { CarouselDemo, CarouselSize, CarouselSpacing, CarouselOrientation, }