6 ms·
Vanilla CSS is all you need
- gherkinnn 10mo agoWe went down a similar path (using Hotwire, non the less!) and got to many of the same conclusions. It is impressive to see what CSS does and how many of the headaches are gone and :has is very powerful. Alas, after several months we tore it all out and went back to React+Tailwind. We still use native HTML popovers and :has selectors and other things we've have learned. But writing UIs across three files (template, stimulus controllers, css) is such a tremendous bore. Concepts that belong together are spread out and I needed to be diligent with placing attributes and classes and remember to remove them all when removing functionality again. Obviously no compile-time checks, just magic strings and runtime errors. The Hotwire docs were also surprisingly hard to work with. All in all a lot of friction. This just was not worth it. inb4 rage, it is possible to use React for the UI alone and pass in fully formed view models, use form submissions and links.
- hexage1814 10mo ago>let me be clear: there is nothing wrong with Tailwind But there is.
- mattstir 10mo agoI'm curious about this. I'm not a frontend engineer but enjoy tinkering on simple frontend UIs for my hobby projects, and I've found Tailwind nice for creating encapsulated components more easily. It's funny that it skips the entire cascading part of Cascading Style Sheets though. Are there major downsides besides that?
- seanwilson 10mo ago> It's funny that it skips the entire cascading part of Cascading Style Sheets though. Are there major downsides besides that? I think cascading is a bad default. It's useful, but only sometimes, and often causes headaches like unintended coupling and confusion about why rules are being overridden. The utility class approach (like Tailwind) makes a lot of issues like this go away. I don't see a good reason why the traditional approach is worth the extra pain or discipline.
- atoav 10mo agoCSS can be laser-like specific if you want it to. Want to only affect that thing? Use ids, inline styles or learn how to write proper selectors. I am by no means a CSS expert, but 90% of CSS issues I heard complaints about boiled down to the complainers not having spent the time necessary to learn the basics. And the other 10% were solved by :has() That being said, most other styling solutions I had used (e.g. in GUI libraries) will quickly make you wish you had CSS.
- seanwilson 10mo ago> CSS can be laser-like specific if you want it to. Want to only affect that thing? Use ids, inline styles or learn how to write proper selectors. You've still go all the normal CSS problems like having to debug complex selectors, jumping between files to debug styling, having to name lots of things you're only going to use once, verbose media queries, verbose styling attributes, and not knowing when it's safe to delete styling because you don't know where it's shared. And for what benefits? To say we're writing CSS "the right way", when it was designed for styling traditional documents and not for complex UIs? This also strikes me as a "if everyone learned to do it properly, there wouldn't be a problem" statement. It's ignoring the reality that nobody can agree on the proper way to write CSS, and writing discipled CSS is fatiguing and time consuming. And even if you could get everyone to adopt the same approach, the above issues are still a big deal. It's a real failing when a language or methodology requires you to invent your own complex discipline to tame it (e.g. C and C++), and get everyone on the team to follow this. At some stage, it's better to scrap everything and try again with what was learned to avoid the mess. > 90% of CSS issues I heard complaints about boiled down to the complainers not having spent the time necessary to learn the basics. And the other 10% were solved by :has() I really don't agree, I understand traditional CSS and how to use complex selectors and it's just not a good approach except mostly for styling traditional Markdown-like documents and adding your own utility classes. If laser-like specific selectors is something I want more of the time, I want this as the default and for it to be easy. Tailwind is a very thin layer above CSS and you can't use it properly without knowing CSS. Coupled with the way you reuse styles in Tailwind by using templates (instead of sharing via classes), it solves most of the problems with CSS in a simple way that people find simple to follow. Tailwind's major downside is it isn't the "traditional" way (which nobody can agree on anyway for complex UI styling), so Tailwind gets attacked for being the wrong way without its benefits and tradeoffs being examined properly.
- Klonoar 10mo agoYes. The cascade model is a bad design.
- tyleo 10mo agoI mostly agree. I prefer vanilla CSS to frameworks but I find a lot of value in CSS modules. In particular I use: 1. The `composes` feature to do something like base classes. 2. The import feature to get something like namespacing. Given the recent advancements in CSS, I won’t be surprised if they eventually build something like `composes` into the base language. The namespacing seems more like an artifact of how you package your website and how you stay organized within your package system (I use webpack).
- charlie-83 10mo agoI like the idea of using vanilla CSS for my personal website but, not being a designer, making something that looks good from nothing is difficult. I've looked at some templates to get started with but they are generally a mess of a million classes I don't need
- Havoc 10mo agoYeah think it’s best to push html css js to the limit & avoid frameworks unless obviously needed. They’re just such a rabbit hole of complexity fragility and lately supply chain risk
- chistev 10mo agoI used to be like this, until I realized Tailwind makes me faster.
- morcus 10mo agoIn the context of determining responsive layout: > Using characters as the unit of measure ensures that we get the right behavior no matter which device you’re using and in a number of other scenarios such as multitasking on iPad or even if you simply enlarge the font size past a certain point. Nice idea! I haven't seen this before.
- roryokane 10mo agoThe section “Utility Classes: Yes, They Still Exist” is unfair in its comparison of Tailwind with pure CSS. It doesn’t take into account Tailwind’s recommendation in https://tailwindcss.com/docs/styling-with-utility-classes#using-components https://tailwindcss.com/docs/styling-with-utility-classes#us... that “if you need to reuse some styles across multiple files, the best strategy is to create a component” in your front-end framework or templating language. So its example of a “typical Tailwind component” is incomplete. A better comparison would use, for example, a React component: function Button({ children }) { return ( <button className="inline-flex items-center gap-2 px-4 py-2 rounded-full border border-gray-300 bg-white text-gray-900 hover:bg-gray-50 focus:ring-2 focus:ring-blue-500" > {children} </button> ); } // Usage: <Button>Save</Button> This would counter all of the article’s arguments in favor of pure CSS. If the website used a `Button` component like this, it would also be true that the “HTML stays readable”, that “changes cascade”, that “variants compose”, and that “media queries live with components”. A better argument against Tailwind would be the added complexity of having a build system and a front-end framework or templating language, if your project doesn’t already have those for other reasons. (adapted from my better-formatted comment at https://lobste.rs/c/oznzzj https://lobste.rs/c/oznzzj)