Skip to main content
Tailwind CSS is a utility-first CSS framework that works seamlessly with Next.js. This page covers installation and usage in the App Router.

Installation

1

Install Tailwind CSS and the PostCSS plugin

2

Add the PostCSS plugin

Create or update postcss.config.mjs at the project root:
postcss.config.mjs
3

Import Tailwind in your global CSS file

app/globals.css
4

Import the CSS file in your root layout

Usage

Once configured, use Tailwind utility classes directly on any element:

Using with CSS Modules

Tailwind and CSS Modules can be used together. Tailwind’s @apply directive lets you compose utilities into a module class:
app/button/button.module.css
app/button/Button.tsx

Dark mode

Tailwind’s dark mode works with Next.js. Add the dark variant to your classes:
app/page.tsx
To enable class-based dark mode, configure it in your CSS:
app/globals.css
If you need support for very old browsers, see the Tailwind CSS v3 setup guide. The @tailwindcss/postcss plugin targets modern browsers by default.