4 ms·
This is not for me. I am very good at, and very comfortable writing CSS since I've been doing it since the CSS Zen Garden days. But I understand the pains this
by armandososa 8y ago
This is not for me. I am very good at, and very comfortable writing CSS since I've been doing it since the CSS Zen Garden days. But I understand the pains this is trying to solve and I think that this is the wrong approach and also the wrong abstraction.
- If you don't like CSS, this will not help you write less CSS, it will only make you write it inline and using a weird syntax.
- If you want to do the sensible thing and compose your styles into components then you'll still have to write CSS with the weird syntax and add a PostCSS to your dev pipeline. Not to mention that you'll still have to have some kind of system for your class naming.
- The order of the clases does not matter, the specificity is decided by the order in which they appear in the source. I can see all kind of untraceable bugs coming from that.
I've used BEM and SMACSS and similar before and I think they are useful as a naming convention for teams but I don't think of them as great tools to writing better CSS. In my humble opinion CSS-in-JS solutions are closer to a great abstraction. I quite like both StyledJSX (for react) and .vue files in which you can write plain css and forget about the global aspects of CSS and the cascade for the most part.
But I can see why some people will dislike that as fiercely as they dislike tailwind.
I think Styled System is a better abstraction than tailwind: https://github.com/jxnblk/styled-system https://github.com/jxnblk/styled-system it's a React library but I can see it's principles could be extracted successfully to plain CSS.
- chrisweekly 8y agoTailwind and CSS-in-JS are not mutually exclusive! On the contrary, they're a terrific match!
- nojvek 8y agoNot really CSS in js is basically applying styles directly to an element, this one declares a small style sheet upfront and classes on elements are looked up to get style information. Css in js is very efficient if you don’t need any css inheritance. Tailwind is just inefficient for the browser to do all those lookups to resolve the final style bag. I’m not sure why I would ever use tailwind. It’s yet another archaic syntax I have to keep in my head.
- chrisweekly 8y agoSorry, but, respectfully, you misunderstand tailwind in the context of css-in-js. This post might make a better case than I have time to right now: https://github.com/jlengstorf/gatsby-tailwind-demo https://github.com/jlengstorf/gatsby-tailwind-demo
- armandososa 8y agoHmm. That's an interesting syntax. I still don't like it and would hate to work on a codebase that used that for styling but I'm happy to know that it exists as an option for people who like tailwind!!