DEV Community

Discussion on: My secret trick for writing great React components

Collapse
 
bertmeeuws profile image
Bert Meeuws

"Always write React components that you can read without scrolling."

Tailwind has entered the chat

Collapse
 
moracabanas profile image
mrcbns • Edited

I usually create old style css name classes and @apply directive to get rid of huge inline classes.

It also let me split styling from behavioural tailwind classes on different @apply directives on the same class so mt-2 is not mixed with hover: and so on

Collapse
 
bertmeeuws profile image
Bert Meeuws

I am in love with tailwind, the way you can just copy paste html and pass it on to a partner and it should look the same (taking position etc. into consideration).

And never having to scroll trough massive css files is worth the hassle of big HTML.

Thread Thread
 
randomusername profile image
Heroe • Edited

Well it may be fine but tailwind didn't invent anything nor there is anything innovative into this approcah, that's just old css utility classes, a bit like bootstrap ( although you'd most likely still use custom css with it since it;s opinionated ) and almost verbatim what tachyons basscss etc have been doing for years.

Thread Thread
 
muhsarip profile image
muhsarip

too many class inside single element, make use of tailwind is harder to read.

Thread Thread
 
victorocna profile image
Victor Ocnarescu

You are perfectly right, Tailwind did not invent anything new and Tachyons did this years ago. In my personal experience I prefer Tailwind over Tachyons because class names have better names for the first one.

Take f5-l which for Tachyons means font-size: 1rem.
Tailwind has font-base which means the same thing.

Thread Thread
 
victorocna profile image
Victor Ocnarescu • Edited

I also love the fact that I do not have to come up with names for classes. In the old days I would say container or container-header, now I just add utility classes like flex flex-col gap-2 and everyone in my team understands the CSS behind it.

Collapse
 
randomusername profile image
Heroe • Edited

What's even the point of using tailwind that way and not just use css/sass ?

Confession: The apply feature in Tailwind basically only exists to trick people who are put off by long lists of classes into trying the framework.
You should almost never use it 😬
Reuse your utility-littered HTML instead

from the creator himself twitter.com/adamwathan/status/1226...