How does scope CSS work?

  Рет қаралды 2,656

Syntax

Syntax

Күн бұрын

Пікірлер
@erikslorenz
@erikslorenz 11 ай бұрын
I think the post react era will be mvc ish with most of the frontend being component based templating that uses pure scoped css and htmx-like partial updates. The reactivity libraries will actually be used as a regular library when you need it. It’s already going that way. These recent css and browser api improvements solve so much of what front end frameworks have been trying to do for most sites and apps
@CjDocious
@CjDocious 11 ай бұрын
Maybe I missed it but is there some way to utilize this to stop inheritance into your components for a site you don't own/cant change the css of? For instance say you have some "widgets" that others can embed on their site. The owners of that site can have all kinds of ugly css and often bleed into the widget. Is there some way in the widget to say "don't inherit anything above me"? Similarly adding a new Micro Frontend to a bloated CSS legacy site. You can make the MFE look great on its own, but as soon as you go to render that MFE in the content area of the legacy site with all kind of un-scoped p, button, whatever css rules, the MFE inherits all that and visually blows up. Is there some way to say at the top level of the MFE "dont inherit any css rules above me"
@robert-m6u7d
@robert-m6u7d 11 ай бұрын
I like this, but what about html size when inline style tag is used a component library? Basically each instance has the same style tag, which doesn’t really make it useful. Also, instead of using tags as selectors, the better approach would be to use slots.
@syntaxfm
@syntaxfm 11 ай бұрын
You would still use selectors for the cascade but for scoped styles specifically it allows you to keep them inside the component exclusively
@m12652
@m12652 11 ай бұрын
So what does @scope do that nested CSS can't?
@syntaxfm
@syntaxfm 11 ай бұрын
Nested css is just simplifying narrowing selectors. @scope allows you to prevent the styles from leaking outside of the scope.
@m12652
@m12652 11 ай бұрын
@@syntaxfm I get how it works and its a nice step forwards, but given I work with components, mostly with svelte, keeping css properly contained isn't really an issue any more (for me). It's even quite pleasant, especially combined with Tailwind etc. For me most of the scenarios where it would have really helped don't really occur that often any more and when they do they're easier to either debug or code around. Funny enough... about 3 seconds after sending my comment you guys pretty much answered my question... I should have deleted it 🙄
@syntaxfm
@syntaxfm 11 ай бұрын
It does nothing that Svelte components can't do for you for sure. But if you use most other stacks it can give you that lovely scoping control.
@m12652
@m12652 11 ай бұрын
@@syntaxfm Svelte does rock
Why Fun Matters | Leader Podcast 026
8:54
CrossCreek Students
Рет қаралды 30
When you have a very capricious child 😂😘👍
00:16
Like Asiya
Рет қаралды 18 МЛН
Support each other🤝
00:31
ISSEI / いっせい
Рет қаралды 81 МЛН
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 30 МЛН
CSS position deep dive
28:14
Kevin Powell
Рет қаралды 114 М.
Node + TypeScript in 2025
18:24
Syntax
Рет қаралды 7 М.
Zero Sync is the Future of Data Loading
29:06
Syntax
Рет қаралды 12 М.
085: Linear easing function fun
16:10
Chrome for Developers
Рет қаралды 3 М.
Naming things just got easier thanks to @scope
26:22
Kevin Powell
Рет қаралды 51 М.
When you have a very capricious child 😂😘👍
00:16
Like Asiya
Рет қаралды 18 МЛН