Introduction
Tailwind CSS is a popular utility-first CSS framework that enables developers to quickly build responsive user interfaces. Tailwind classes can be used to style HTML elements. Most developers prefer this framework because it gives them control over components.
In this article, we'll go over how to install Tailwind CSS into our project in these simple steps.
How to Install Tailwind CSS
Take the following steps to install Tailwind CSS:
Create an
index.html
file in your code editor.Open your terminal, input the code and press enter. This command creates a
package.json
file.npm init
Install the Tailwind CSS package. These commands initializes and creates a
tailwind.config.js
file.npm install -D tailwindcss npx tailwindcss init
Now, enter your
tailwind.config.js
file. Copy and paste the code below. This is where we intend to use our Tailwind CSS files./** @type {import('tailwindcss').Config} */ module.exports = { content: ["./src/**/*.{html,js}"], theme: { extend: {}, }, plugins: [], }
Create an
src
(source) folder.Create an
input.css
file in thesrc
folder.Copy and paste the following lines of code into your
input.css
file.@tailwind base; @tailwind components; @tailwind utilities;
Start your Tailwind CSS
npx tailwindcss -i ./src/input.css -o ./dist/output.css --watch
And that's it! Happy Coding!