In this post, weβll install Tailwind CSS in a Next.js project and understand how everything connects step by step.
By the end, youβll have a fully working setup ready for building modern UIs.
π Step 1: Create a Next.js Project
First, create a new Next.js app:
npx create-next-app@latest my-tailwind-appThen move into your project folder:
cd my-tailwind-appπ¨ Step 2: Install Tailwind CSS
Now install Tailwind and required dependencies:
npm install -D tailwindcss postcss autoprefixerGenerate the config files:
npx tailwindcss init -pThis creates:
tailwind.config.js
postcss.config.js
βοΈ Step 3: Configure Tailwind
Open your tailwind.config.js file and update it like this:
export default {
content: [
"./app//*.{js,ts,jsx,tsx}",
"./pages//.{js,ts,jsx,tsx}",
"./components/**/.{js,ts,jsx,tsx}",
],
theme: {
extend: {},
},
plugins: [],
};π Why this step matters
This tells Tailwind:
π βScan these files and generate only the CSS we actually use.β
This keeps your final CSS file small and optimized.
π― Step 4: Add Tailwind to Global CSS
Open:
app/globals.css
Replace everything with:
@tailwind base;
@tailwind components;
@tailwind utilities;π§ͺ Step 5: Test Tailwind in Next.js
Now open app/page.js (or page.tsx) and add this:
export default function Home() {
return (
<div className="min-h-screen flex items-center justify-center bg-gray-100">
<h1 className="text-4xl font-bold text-blue-600">
Tailwind CSS is Working π
</h1>
</div>
);
}π§ What Just Happened?
Letβs break it down:
min-h-screen β full screen height
flex β enables flexbox
items-center β vertical centering
justify-center β horizontal centering
bg-gray-100 β light background
text-4xl β large text
font-bold β bold text
text-blue-600 β blue color
You just built a centered UI without writing a single custom CSS file.
β‘ Why This Setup is Powerful
Once Tailwind is installed:
You never write repetitive CSS again
Your UI becomes faster to build
Design stays consistent
Works perfectly with React & Next.js
This is why modern companies prefer Tailwind for frontend development.
π§© Common Mistakes (Avoid These)
β Forgetting to add content paths in config
β Not restarting dev server after setup
β Editing wrong globals.css file
β Missing @tailwind directives
π§ Whatβs Next?
In the next post, weβll build your first real component:
π A Responsive Navbar using Tailwind CSS
This is where things start getting real-world practical.



