How to Install Tailwind CSS with Next.js
A step-by-step guide to setting up and installing Tailwind CSS with your Next.js project.
Step 01: Create Your Project
The first step in the process is to create a brand new Next.js project. The preferred route is to use Create Next App;
Step 02: Install Tailwind CSS
The second step is to install tailwindcss
and its dependencies. This can be done with npm and then run the init command to have both the tailwind.config.js
and postcss.config.js
generated.
Step 03: Template Path Configuration
The third step of the process is adding the paths to all of your template files in the tailwind.config.js
file.
Step 04: Adding The Tailwind Directives To The CSS
Next, you will add the @tailwind
directives for each of Tailwind's layers to the @globals.css
file.
Step 05: Start the build process
Lastly, run the build process with npm run dev
.
Step 06: Begin the build process
And there you have it! You are now ready to begin using Tailwind's utility classes to style the content in your Next.js project.