Lost in Transition: How to Downgrade to Tailwind CSS v3 in Next.js And React
Yogesh Chavan

Yogesh Chavan @myogeshchavan97

About: React Trainer | MERN Trainer | Full Stack Developer | JavaScript | React | Nodejs. Connect with me for mentoring session: https://www.codementor.io/@myogeshchavan97

Location:
India
Joined:
Apr 6, 2020

Lost in Transition: How to Downgrade to Tailwind CSS v3 in Next.js And React

Publish Date: Mar 10
18 14

The recent release of Tailwind CSS v4 has brought about significant changes.

One of the most noticeable differences is the absence of a tailwind.config.js file when creating a new Next.js application. This has left many developers confused, especially when trying to follow tutorials or videos that use Tailwind CSS v3.

While mentoring on Codementor, I have seen many developers struggling with this issue.

If you're one of them, don't worry! Here's a step-by-step guide on how to use Tailwind CSS v3 in your Next.js and React.js project.

Why Downgrade to Tailwind CSS v3?

While Tailwind CSS v4 offers many exciting features, some developers might prefer to stick with v3 for various reasons, such as compatibility issues or familiarity with existing projects. Whatever your reason, downgrading is straightforward.

Steps to Downgrade to Tailwind CSS v3

Step 1: Uninstall Tailwind CSS v4

First, you need to uninstall the installed Tailwind CSS v4. You can do this by running the following command in your terminal:

npm uninstall tailwindcss
Enter fullscreen mode Exit fullscreen mode

Step 2: Install Tailwind CSS v3

Next, install Tailwind CSS v3 along with other necessary dependencies using the following command:

npm install -D tailwindcss@3.4.17 postcss autoprefixer
Enter fullscreen mode Exit fullscreen mode

Step 3: Create a Tailwind Config File

Now, create a tailwind.config.js file by executing this command:

npx tailwindcss init -p
Enter fullscreen mode Exit fullscreen mode

Step 4: Configure the Content Array

Open the newly created tailwind.config.js file and update the content array to include your project's paths.

  • For Next.js Projects: Replace the existing content with the following code:
content: [
  "./pages/**/*.{js,ts,jsx,tsx,mdx}",
  "./components/**/*.{js,ts,jsx,tsx,mdx}",
  "./app/**/*.{js,ts,jsx,tsx,mdx}",
],
Enter fullscreen mode Exit fullscreen mode
  • For Vite + React.js Projects: Use the following configuration instead:
content: [
  "./pages/**/*.{js,ts,jsx,tsx,mdx}",
  "./components/**/*.{js,ts,jsx,tsx,mdx}",
  "./app/**/*.{js,ts,jsx,tsx,mdx}",
  "./src/**/*.{js,ts,jsx,tsx,mdx}",
],
Enter fullscreen mode Exit fullscreen mode

Step 5: Update Your Global CSS File

Finally, add the following lines to your main global.css or index.css file:

@tailwind base;
@tailwind components;
@tailwind utilities;
Enter fullscreen mode Exit fullscreen mode

You're Done!

By following these steps, you should now have Tailwind CSS v3 up and running in your Next.js and React.js project.

This setup will allow you to continue using the features and configurations you're familiar with from v3, making it easier to follow older tutorials or maintain existing projects.

Happy coding!

Connect With Me

Comments 14 total

  • Dishant Gusain
    Dishant GusainMar 14, 2025

    Thank you for this post, I was going insane without tailwind.config file. Created account just for this comment.

    • Yogesh Chavan
      Yogesh ChavanMar 14, 2025

      haha. You're not alone. Glad you found it helpful. Thanks for reading!

  • Abdulrazaq Salihu
    Abdulrazaq SalihuApr 7, 2025

    Thanks a lot man, this was beyond helpful.

    • Yogesh Chavan
      Yogesh ChavanApr 8, 2025

      Glad you found it helpful. Thank you🙏

  • keyuan DY
    keyuan DYApr 16, 2025

    cool. thanks

    • Yogesh Chavan
      Yogesh ChavanApr 16, 2025

      Glad you found it helpful. Thank you🙏

  • Gwepura
    GwepuraApr 22, 2025

    You are a heaven-sent! I was about to close my laptop and go to sleep🤣🤣

    • Yogesh Chavan
      Yogesh ChavanApr 23, 2025

      Haha. Glad to hear it was helpful to you. Thank you🙏

  • Saestwo
    SaestwoMay 1, 2025

    The compatibility issue is pretty stressful, thank you!

  • Maulana Adam Sahid
    Maulana Adam SahidMay 15, 2025

    TailwindCSS's CSS config file is bad. But you are best 😁

  • Samadhee Samarasinghe
    Samadhee SamarasingheMay 27, 2025

    Thank you so much. This was really helpful.

Add comment