99

Concurrent visitors over the last 30 minutes. (~)

Peak concurrent visitors -
Yesterday: 0 / Today: 0

Getting Started with the New Tailwind CSS v4 in a Next.js Project

CSSTailwindcssNext
2 years ago / 2 years ago
0

Tailwind CSS v4 was officially released on January 23.
Along with its major changes, it brings even better performance and usability.

  • Builds up to 100x faster
  • Minimal installation and configuration code
  • Makes full use of modern CSS features (@layer, @property, color-mix(), and more)
  • Support for container queries, 3D transforms, and a new color system
  • More intuitive customization, configured directly in CSS without JS

When you create a new project with the latest Next.js 15, Tailwind CSS v4 is applied by default.
If you want to use Tailwind CSS v4 in an existing Next project, set it up with the following steps.

First, install each package at its latest version.

BASH
1
npm i -D tailwindcss@4 postcss @tailwindcss/postcss
Install the latest packages

Change the option name in the PostCSS configuration.

/postcss.config.mjs
MJS
1
2
3
4
5
6
7
8
9
/** @type {import('postcss-load-config').Config} */ const config = { plugins: { // tailwindcss: {} "@tailwindcss/postcss": {} } } export default config
Change the PostCSS configuration

Also change the style code that you import globally.

/app/globals.css
CSS
1
2
3
4
5
6
/* @tailwind base; @tailwind components; @tailwind utilities; */ @import "tailwindcss"; /* Omitted.. */
Change the global styles