Installing Tailwind CSS in a React app
Last updated
Was this helpful?
Last updated
Was this helpful?
In this demo Iβm going to assume you have created an app using Vite, like I showed you in .
Now I want show you how to install Tailwind CSS.
In the terminal, run this command to install these dependencies:
followed by
This command creates a file called tailwind.config.js
which contains this:
Now open this file with VS Code and add to the content
field the places where we might find the Tailwind classes weβre going to write:
This setting will be used by Tailwind to determine where to look to generate the CSS file.
Now in the src/index.css
file add those 3 lines:
(you can remove all the other content, which most probably you will not use)
Restart the app with npm run dev
and Tailwind should be enabled.
You should see something like this:
Now for example try changing your App.tsx
/ App.jsx
to this:
It should work:
Thatβs it, we installed Tailwind CSS successfully.