Setup Requirements
Project Structure Requirements
shadcn project structure
Tailwind CSS
TypeScript
Setup Instructions
1. Setting up shadcn project structure
npx create-next-app@latest my-app --typescript --tailwind --eslint
This creates a Next.js project with TypeScript, Tailwind CSS, and ESLint.
2. Install shadcn CLI
npm install -D @shadcn/ui
This installs the shadcn CLI as a development dependency.
3. Initialize shadcn
npx shadcn-ui@latest init
This initializes shadcn in your project and sets up the required configuration.
4. Create components/ui directory
mkdir -p components/ui
This creates the components/ui directory where shadcn components will be stored.
5. Create lib/utils.ts file
mkdir -p lib touch lib/utils.ts
Add the following code to lib/utils.ts:
import { type ClassValue, clsx } from "clsx"
import { twMerge } from "tailwind-merge"
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
Component Structure
The default path for components in a shadcn project is:
/components/ui
This directory structure is important because:
- It separates UI components from other components
- It follows the shadcn convention for component organization
- It makes it easier to find and reuse components
- It helps maintain a consistent project structure