Skip to main content
Starting fresh? Use shadcn/create to save time. It handles Tailwind, TypeScript, and path alias configuration for you, plus custom themes and presets.
1
Create project
2
Start by creating a new React project using vite. Select the React + TypeScript template:
3
npm create vite@latest
4
Add Tailwind CSS
5
npm install tailwindcss @tailwindcss/vite
6
Replace everything in src/index.css with the following:
7
@import "tailwindcss";
8
Edit tsconfig.json file
9
The current version of Vite splits TypeScript configuration into three files, two of which need to be edited. Add the baseUrl and paths properties to the compilerOptions section of the tsconfig.json and tsconfig.app.json files:
10
{
  "files": [],
  "references": [
    {
      "path": "./tsconfig.app.json"
    },
    {
      "path": "./tsconfig.node.json"
    }
  ],
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@/*": ["./src/*"]
    }
  }
}
11
Edit tsconfig.app.json file
12
Add the following code to the tsconfig.app.json file to resolve paths, for your IDE:
13
{
  "compilerOptions": {
    // ...
    "baseUrl": ".",
    "paths": {
      "@/*": [
        "./src/*"
      ]
    }
    // ...
  }
}
14
Update vite.config.ts
15
Add the following code to the vite.config.ts so your app can resolve paths without error:
16
npm install -D @types/node
17
import path from "path"
import tailwindcss from "@tailwindcss/vite"
import react from "@vitejs/plugin-react"
import { defineConfig } from "vite"

// https://vite.dev/config/
export default defineConfig({
  plugins: [react(), tailwindcss()],
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "./src"),
    },
  },
})
18
Run the CLI
19
Run the shadcn init command to setup your project:
20
npx shadcn@latest init
21
You will be asked a few questions to configure components.json.
22
Which color would you like to use as base color? › Neutral
23
Add Components
24
You can now start adding components to your project.
25
npx shadcn@latest add button
26
The command above will add the Button component to your project. You can then import it like this:
27
import { Button } from "@/components/ui/button"

function App() {
  return (
    <div className="flex min-h-svh flex-col items-center justify-center">
      <Button>Click me</Button>
    </div>
  )
}

export default App

Build docs developers (and LLMs) love