,

How to Install Tailwind CSS in NextJS 13

Posted by

Installing Tailwind CSS in NextJS 13

Installing Tailwind CSS in NextJS 13

If you are looking to style your NextJS 13 application with Tailwind CSS, you are in the right place! Tailwind CSS is a popular utility-first CSS framework that allows you to quickly style your web applications.

  1. First, create a new NextJS 13 project or open an existing one.
  2. Install Tailwind CSS and its dependencies by running the following command in your terminal:
npm install tailwindcss@latest postcss@latest autoprefixer@latest

You will also need to create a Tailwind CSS configuration file. You can do this by running the following command:

npx tailwindcss init -p

This will create a `tailwind.config.js` file in your project directory.

Next, you need to create a CSS file to import Tailwind CSS styles. Create a new file, for example, `styles/tailwind.css`, and add the following code:

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

Finally, import the `tailwind.css` file in your NextJS project. You can do this by adding the following line of code to your `_app.js` file:

import '../styles/tailwind.css'

And that’s it! You have successfully installed Tailwind CSS in your NextJS 13 project. You can now start using the utility classes provided by Tailwind CSS to style your components.

Happy styling!