Next.js supports multiple ways to style your app, each solving a different problem.
| Method | Scope | When to Use |
|---|---|---|
| Tailwind CSS | Utility classes | Most UI styling |
| CSS Modules | Component-scoped CSS | Custom component styles |
| Global CSS | Entire app | Base styles / resets |
Next, install Tailwind and the required PostCSS dependencies.
npm install tailwindcss @tailwindcss/postcss postcss
These packages allow Tailwind to process your CSS during the build step.
Create a file named postcss.config.mjs in the root of the project:
const config = {plugins: {"@tailwindcss/postcss": {},},};export default config;
This tells PostCSS to use the Tailwind plugin when compiling CSS.
Open the global stylesheet:
app/globals.css
Add the following line:
@import "tailwindcss";
This imports Tailwind’s base styles, components, and utility classes.