4 ms·
> Instead of writing CSS, I add classes to my HTML. Ok, but I don't want to rewrite everything all the time, it would be like using the inline style attribute.
by seanwilson 5y ago
> Instead of writing CSS, I add classes to my HTML. Ok, but I don't want to rewrite everything all the time, it would be like using the inline style attribute.
> Ok, then I install PostCSS, and start writing classes with @apply. Wait, hang on, isn't that just writing plain old CSS with a new syntax and new names to learn?
These questions are covered in the basic docs:
https://tailwindcss.com/docs/reusing-styles https://tailwindcss.com/docs/reusing-styles
https://tailwindcss.com/docs/utility-first https://tailwindcss.com/docs/utility-first
- Reuse styles using components, not classes.
- Inline styles don't allow responsive behaviour, utility classes do.
The above also comes with accepting that the plain old CSS approach doesn't scale and makes you do stuff ("best practices") for no real benefit; it pushes you to make premature abstractions, name things that don't need to be named, and split things up between files that don't need to be split up.
If you don't agree with this though (more likely if you don't work on complex designs), you'll be fighting against Tailwind. Saying that, I think a lot of people comment without having read the basic docs and are having knee jerk reactions to what they see as going against best practices without really trying to understand it or weigh up the pros and cons.