3 ms·
I don't know how it works in Svelte, but react+MUIv4 (makeStyles) is effectively component scoped as well, in that your selectors will have a random prefix gene
by koromak 3y ago
I don't know how it works in Svelte, but react+MUIv4 (makeStyles) is effectively component scoped as well, in that your selectors will have a random prefix generated unique to each component.
I actually find this really obnoxious. Its super common to want a child component to change styles based on the parent component its wrapped by, sometimes far up the tree. The only way to do this is prop drilling to pass a class, or start putting vanilla selectors everywhere the parent can target. I don't really see the usefulness. CSS isn't naturally isolated like that.
- 9dev 3y agoFrom my experience, this is a natural reaction at first, but there aren’t that many use cases that warrant global styles when you’re working in a component-oriented framework. Passing props or using state is the way to tell a child component to dress differently, even though it sometimes gets burdensome. Anytime I tried using global styles, at some point something went haywire I didn’t account for. On the other hand, for styling HTML generated or fetched from somewhere (e.g. CMS content, rendered Markdown), it’s obviously necessary.
- Sankozi 3y agoI disliked it at first too but now I consider migrating to such solution. I am starting to tolerate CSS as a set of style properties, but I still hate CSS as a stylesheet files with various rules with unclear dependencies. Very quickly they become extremely brittle. It is also hard to modularize them in any sensible way. Unless your web app is one SPA with one set of CSS files any change is risky and may affect multiple pages in surprising ways.