2 ms·
> Also, if you are using utility classes why not just inline CSS? "red-border white-background pad-20" is just as bad. Those of us who’ve used Tailwind in part
by inopinatus 7y ago
> Also, if you are using utility classes why not just inline CSS? "red-border white-background pad-20" is just as bad.
Those of us who’ve used Tailwind in particular might write “just as good, but better”. The utility classes are satisfyingly regular and well documented. They are higher level than inline CSS, and though obviously congruent, I'd reject a claim of direct equivalence.
Tailwind is to inline styles what assembler is to machine code, and that’s a good thing. With inline styles there is no opportunity to use combinatorial selectors, or to specify units, breakpoints, and other stylistic preferences as part of the compiled utilities.
My experience of a semantic or domain-specific approach to class-based styling is a drop in maintainability and a rise in complications, duplication, and special cases. Especially so in larger, componentised applications. Thinking of elements as purely on-page structures (and not representational of anything greater) helps avoid layering violations, promotes generality of style, and creates more opportunities for extension and substitution.
- ehnto 7y agoI have heard good things about tailwind. Do you find a lack in flexibility with Tailwind? To use the same example, what if the client wants a product card to look different on the home page compared to the listing page, and again in the mini cart and checkout? One approach I have seen is four different components for each location, in which case you have traded cascading of CSS for duplication of markup/logic code.