• Blog
  • Documentation
  • Courses
  • Changelog
  • AI Starters
  • UI Kit
  • FAQ
  • Supamode
    New
  • Pricing

Launch your next SaaS in record time with Makerkit, a React SaaS Boilerplate for Next.js and Supabase.

Makerkit is a product of Makerkit Pte Ltd (registered in the Republic of Singapore)Company Registration No: 202407149CFor support or inquiries, please contact us

About
  • FAQ
  • Contact
  • Verify your Discord
  • Consultation
  • Open Source
  • Become an Affiliate
Product
  • Documentation
  • Blog
  • Changelog
  • UI Blocks
  • Figma UI Kit
  • AI SaaS Starters
License
  • Activate License
  • Upgrade License
  • Invite Member
Legal
  • Terms of License

Add Tailwind CSS to Next.js

Aug 3, 2022

Learn how to install and use Tailwind CSS in your Next.js website

Tailwind CSS is the hottest CSS framework in the past few years: it's fun and easy to use, with wonderful defaults that make designing beautiful UIs a breeze.

To install TailwindCSS in your Next.js project, run the following command:

npm install -D tailwindcss postcss

Initialize the Tailwind CSS configuration

Afterward, we run the following command to initialize the Tailwind configuration:

npx tailwindcss init

This will create a file named tailwind.config.js in your root folder. We have to change the content glob to use files with the tsx extension:

/** @type {import('tailwindcss').Config} */
module.exports = {
content: ["./**/*.{tsx}"],
theme: {
extend: {},
},
plugins: [],
}

Add the PostCSS configuration file

Additionally, we have to create a postcss configuration that Next.js will automatically pick up. To do so, create a file names postcss.config.js in your root folder and add the following content:

module.exports = {
plugins: {
tailwindcss: {},
},
};

Import Tailwind CSS in your styles

At this point, we have to import Tailwind CSS in your global styles, normally located at styles/index.css. To do so add the following content to your main CSS file:

@tailwind base;
@tailwind components;
@tailwind utilities;

To test if this works, visit your home page at pages/index.tsx and add some styles such as:

<h1 className='text-5xl'>
This is Tailwind CSS with Next.js!
</h1>

Installing the Tailwind CSS Prettier plugin

If you're using Prettier, you can install a plugin to automatically sort the class names in your HTML tags according to the best practices prescribed by the Tailwind CSS team, so to make your code clean and consistent.

To install the Prettier plugin, use the following command:

npm i prettier-plugin-tailwindcss

If it's all good, you don't have to do anything else, it will simply work when running Prettier, which we recommend doing each time you save your files.

Some other posts you might like...
Oct 22, 2025Next.js 16: what's new?Next.js 16 is a major release that includes several new features and improvements. In this article, we will cover the new features and improvements in Next.js 16.
Oct 19, 2025React 19.2: Upgrade GuideReact 19.2 introduces the Activity component, useEffectEvent hook, Partial Pre-rendering, and Chrome DevTools Performance Tracks. Learn about all the new features and improvements in this comprehensive guide.
Oct 13, 2025Build a Production Supabase Blog in Next.js with Supamode CMSLearn how to design a Supabase blog schema, build a Next.js UI, and wire up Supamode CMS so your team can publish fast without touching SQL
Sep 25, 2025Mastering AI-Driven Development: Claude Code & Makerkit Best PracticesA comprehensive guide to building production-ready SaaS features using Claude Code's intelligent agents and Makerkit's PRD functionality