I used to hate Tailwind CSS
Why would I even need it? After all, I love Vanilla CSS so much. and Tailwind is also built upon Vanilla CSS. The first time I saw Tailwind CSS used on a project and seeing so many classes in the HTML file, it had me rolling.
Why Does This Happen?
- Yes, now I need to learn yet another framework. At that time, I had already learned HTML, CSS, JavaScript, React, and Next.js. I thought I was done and didn't need to learn anything else (wrong mindset).
- When you don’t know anything about a thing, you become scared, and you hate even trying.
- I started Googling "why you shouldn't use Tailwind CSS", "how Tailwind CSS is bad", etc. You know what kind of information and videos you can find on Google and YouTube.
- Most of the content on that platform is created by people who will do anything for views. Additionally, you don't know the person you're watching or reading. Do they really have experience with development? Are they good developers?
Let's compare Vanilla CSS and Tailwind CSS.
Vanilla CSS
Here, I'm using Vanilla CSS. Now there are pros and cons of using it
Pros of Vanilla CSS:
- You can clearly see HTML structure.
- There is no mess in HTML files with CSS classes.
- You have full control, allowing you to style each class as needed.
- A separate CSS file for organization.
Cons of Vanilla CSS:
- You need to create unique CSS class names for each element, and ensuring they don't match can be frustrating, especially on larger projects with numerous files
- When viewing the HTML file, you don’t know which CSS is applied there.
- You need to constantly switch to the CSS file to check which styles are applied there.”
- You need to create a separate CSS file, which can become quite lengthy, especially in large projects where it may extend to thousands of lines of CSS code.
Tailwind CSS
Here I am using Tailwind CSS, Yes only one file.
Pros of Tailwind CSS:
- You don’t need an extra CSS file.
- You can clearly see which CSS is applied to each element.
- When you add Tailwind to a project, all default HTML styles are automatically removed.
- No need to think about what class name to give.
- Consistency in style.
- Flexible classes; you are not limited to default Tailwind classes. For example, "text-xl" typically means a 20px font size, but you can customize your own sizes, like "text-[69px]". This is just a small example of the many possibilities Tailwind CSS offers.
- And most importantly, many companies use Tailwind CSS. In job requirements, many companies require familiarity with it.
Cons of Tailwind CSS
- If you add too many Tailwind classes, the HTML file can look overwhelming. (You can use a VS Code extension to hide all the Tailwind classes, allowing you to focus on the HTML structure.)
- You need to learn Tailwind CSS 😂.
Both code samples are from my Weather Forecast project. I initially built this project with Vanilla CSS and JavaScript and later built with Tailwind CSS and TypeScript.
Now How to Properly Learn Tailwind CSS
If you've clicked on this blog, you likely already have an idea about Tailwind CSS and may have even tried it by watching YouTube tutorials. However, learning Tailwind CSS from YouTube tutorials is one of the biggest mistakes you can make.
If you're a complete beginner in Tailwind, you can watch tutorials just to grasp the basic idea. However, I highly recommend learning by yourself on your own projects using the Tailwind CSS documentation.
Why? Because I also started learning Tailwind CSS by watching YouTube tutorials, and I understood the basics. However, I couldn't implement it effectively on my own, and the abundance of classes in Tailwind overwhelmed me. Despite learning it, I didn't become proficient, so I didn’t used Tailwind in any of my projects.
Then, one day, I decided to give it another try. This time, I decided to learning it by myself, building projects, and using Tailwind documentation. And you know what? I became very good at it. It became so much easier to use. When you learn and use it yourself, you will understand why Tailwind CSS is the best and why so many people use it.
Here’s how to learn:
Now, if you want to change the background color of a div, go to the Tailwind documentation, search for "background color," and then apply that class.
Similarly, if you want to apply a border, go to the documentation, search for "border," and then use the relevant class.
If you've built 1 or 2 projects with Tailwind CSS completely by yourself, you will become very good at it & It will feel easy and simple, and you will also love it, just like me
Helpful VS Code Extensions
This extension provides auto-completion and suggests Tailwind CSS classes.
This extension enables you to hide all the classes so you can focus on the HTML structure.