Hacker News new | ask | show | jobs
by ess3 968 days ago
I’m still looking for a lightweight solution (no react etc) that lets me write normal CSS but scoping it to an arbitrary part of my HTML tree. Most of the time I’ll be working in a partial where I know what generic names such as .container refers to And I don’t want to bother with coming up with unique names.

The best I can think of is to use descendant selectors but that increases the specificity and is hard to maintain imo.

Excited to see what the @scope feature draft can bring to this

2 comments

I am currently undoing nextjs out of a side project (where I spent 2 months learning react/next as it seemed like everyone knew something I didn't). I think I got pretty good at it and frankly the only useful thing I get about is it were - I think you referred to as - "isolated css". Frankly I found the whole shebang way too complicated and bloated and just was not worth being stuck to Node as a backend (I am fairly comfortable (dare I say formidable) with golang and don't see a need - for me - to switch.

On fe html/Templates+webpack (scss for variables and typescript) has taken me very far with a clean and fast build step and more importantly dependencies don't break every few months!

One downside though is remembering why a particular "css" after a while. But i am not a particularly fe/styling person so my css is simple. May tailwind is for the Uber fe/design crowd!

Me too. Unfortunately the browser support for @scope is very low atm. Cascade layers are one way to decrease specifity and are well supported [1].

[1]: https://caniuse.com/css-cascade-layers