This is a guide on how to simply set up a new Vite + React + TypeScript project with Tailwind CSS and Shadcn/ui components from scratch, as of 22ndApril, 2025.
npm create vite@latest my-app -- --template react-ts
cd my-app
npm install
npm install -D tailwindcss@^3.4 postcss@^8 autoprefixer@^10
npx tailwindcss init -p
tailwind.config.js
/** @type {import('tailwindcss').Config} */
export default {
content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
theme: {
extend: {},
},
plugins: [],
};
src/index.css
@tailwind base;
@tailwind components;
@tailwind utilities;
tsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
},
"jsx": "react-jsx",
"esModuleInterop": true
}
}
vite.config.json
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import path from "path";
export default defineConfig({
plugins: [react()],
resolve: {
alias: {
"@": path.resolve(__dirname, "src"),
},
},
});
npm install @radix-ui/react-slot class-variance-authority clsx tailwind-variants
npx shadcn@latest init
I usually use the following:
Install the button component:
npx shadcn@latest add button
Note: We use --force flag for now.
Update src/App.tsx
to test the button:
import { useState } from "react";
import { Button } from "@/components/ui/button";
function App() {
const [count, setCount] = useState(0);
return (
<div className="p-4 bg-gray-100 min-h-screen flex flex-col items-center justify-center">
<h1 className="text-2xl font-bold mb-4">
Vite + React + TypeScript project with Tailwind CSS and Shadcn/ui
components
</h1>
<Button onClick={() => setCount(count + 1)}>Count is {count}</Button>
<p className="mt-12 text-sm font-thin text-gray-700">
If you liked this resource, give it a star on{" "}
<a
href="https://github.com/Lightxxo/vite-react-typescript-tailwind-shadcn-template"
target="_blank"
rel="noopener noreferrer"
className="text-blue-500 underline"
>
GitHub
</a>
!
</p>
</div>
);
}
export default App;
Start the dev server:
npm run dev
โ
You should see the button styled with Tailwind and shadcn/ui.
ยฉ๏ธ For future reference only. All steps verified to work as of 22ndApril, 2025.