Hacker News new | ask | show | jobs
by simion314 880 days ago
What makes tailwind feel wrong for me is that you put the css classes everywhere exactly like you would set inline style attribute. I would prefer using the css slectors and select by an id or class name and apply a css like that. I avoid frontend but this is how I see it used in my team.

Would be nicer if you could do it like selector > color-xyz text0xyz paddifng-xyz and never add those classes inline

2 comments

Oh yeah it does feel weird “dirty” somewhat.

But to your suggestion - you can! Thats what components classes do in essence. When you have a bunch of styles that _always_ go together - you bunch em up.

But in practice it is usually simpler to keep the classes and use other templating features of your platform to achieve this.

It becomes extremely nice as every time you need the question “why is my html look like this” answered, there is no hierarchy of other files to dig through - its all just there.

And as with any tool you can abuse it in ways that are not intended - seen plenty of ugly tailwind examples with tons of weird unruly code. But thats even more true for css itself. Omg the horrors I’ve seen with custom raw css cans still give me nightmares.

I know there are many tutorials doing that, but that is not how I use Tailwind. Tailwind entirely supports your own CSS files and you can use @apply to compose all of the existing classes together.
Thanks for the tips