Installation
How to install carouselcn in your project.
Prerequisites
You need a React project with Tailwind CSS configured. The component also uses:
lucide-reactfor icons (ChevronLeft, ChevronRight, etc.)- A
cnutility function for classnames (standard in shadcn/ui projects)
Option 1: CLI Install
Use the shadcn CLI to add the component directly to your project:
pnpm dlx shadcn@latest add https://carouselcn.vercel.app/r/carousel.jsonor
If you are using a namespaced registry, you can use the following command:
pnpm dlx shadcn@latest add @carouselcn/carouselThis will add carousel.tsx to your components/ui folder.
Option 2: Manual Copy
Copy the component code directly from the Carousel component page and paste it into your project at components/ui/carousel.tsx.
Make sure you have the cn utility. If not, create lib/utils.ts:
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}And install the dependencies:
npm install clsx tailwind-merge lucide-reactUsage
import {
Carousel,
CarouselContent,
CarouselItem,
CarouselNavigation,
CarouselIndicator,
} from "@/components/ui/carousel";See the Carousel docs for full API reference and examples.