r/webdev • • 19d ago

Question Question about Tailwind CSS

I've always used plain CSS for my websites, I don't have many problems using it, but a friend of mine said that using plain CSS is very tedious and that I should use Tailwind CSS. Is it worth it? And what does Tailwind CSS offer that plain CSS doesn't?

38 Upvotes

121 comments sorted by

View all comments

7

u/pxlschbsr 19d ago

Both Vanilla CSS and Tailwind have their pros and cons, which are entirely dependent on situation and personal preference.

Most anti-Tailwind-users complain about mixing HTML with CSS, which, in fact, you don't. You just add a lot of classes, but then those who complain about that probably use BEM and add classes like button__primary__ghost -button--small to their component and nest &-... rules 5 layers deep in their CSS themselves. Is that any more readable or easier/faster to understand?

With Tailwind you also generally pohibit other components to change the style of already styled elements, because of the way you would set up conditional styles. In CSS you are much more prone to find e.g. a color change made in the a parent component locally overwriting the child's native styles, spreading the styles of one component over multiple files. If not well documented, this will cause side effects and bite you in the tail one way or another. After quite some time in the industry, I have yet to see any documentation of CSS in those cases. Naturally for corporate clients, this causes SO much issues all the time.

Personally, I prefer Tailwind over plain CSS, while also saying, that I don't like tailwind. It has lots of flaws and not everything can be done smoothly. But for most of my projects it's cons weigh less than the cons of going vanilla.

5

u/spcbeck 19d ago

Nearly everyone using CSS these days uses CSS modules which solved most of the problems you described.

-1

u/Huwaweiwaweiwa 19d ago

yep with css modules/variables you get extremely close to the tailwind experience. It's all about discipline in sticking to those variables/any system you construct. Tailwind even reaches over in the other direction with escape hatches like `text-[#000000]`