R
Rishtaara
Next.js: Zero to Full-Stack
Lesson 6 of 42Article14 min

Install Tailwind CSS & Material UI

Modern create-next-app can enable Tailwind for you. If you start without it, install the Tailwind packages and create the config files Next expects.

Tailwind CSS setup for Next.js

Modern create-next-app can enable Tailwind for you. If you start without it, install the Tailwind packages and create the config files Next expects.

After setup, add the Tailwind directives to your global stylesheet so utilities work everywhere.

Real-life example: Installing Tailwind is stocking a spice rack — once jars are labeled and on the shelf, every recipe (component) can grab salt and chili fast.

Tip: If create-next-app already added Tailwind, skip reinstalling. Just confirm globals.css has the Tailwind import and restart npm run dev.
Install Tailwind (v4-style with PostCSS)
npm install tailwindcss @tailwindcss/postcss postcss
postcss.config.mjs
const config = {
  plugins: {
    "@tailwindcss/postcss": {},
  },
};

export default config;
Add directives in app/globals.css
@import "tailwindcss";

/* Your custom base styles below */
body {
  margin: 0;
}

Verify Tailwind works

Add a utility class on the home page. If the style appears, Tailwind is connected. If not, check the CSS import path and restart the dev server.

Real-life example: Verification is tasting the soup after adding salt — one spoon tells you if the kitchen setup worked.

Quick Tailwind smoke test
export default function Page() {
  return (
    <h1 className="text-3xl font-bold underline text-sky-700">
      Tailwind is working
    </h1>
  );
}

Optional — Material UI (MUI)

Material UI is a React component library with buttons, dialogs, and themes. It is optional — many Next.js apps use Tailwind alone.

MUI components need a Client Component boundary because they use browser APIs and theme context. Install the packages, then wrap interactive UI as needed.

Real-life example: MUI is buying ready-made furniture for one room. Tailwind is painting and arranging yourself. You can use both carefully, but start with one primary system.

Tip: Prefer one main styling system for beginners. Learn Tailwind deeply first; add MUI later if your team already uses it.
Optional MUI install
npm install @mui/material @emotion/react @emotion/styled
Client component using MUI Button
"use client";

import Button from "@mui/material/Button";

export function MuiDemo() {
  return (
    <Button variant="contained" color="primary">
      Rishtaara MUI Button
    </Button>
  );
}