How does scope CSS work?

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

Syntax

Syntax

Күн бұрын

In this very hasty treat, Wes and Scott cover CSS Native @scope, the implementation of this tool, and some of its limitations.
Show Notes:
00:00 Welcome to Syntax!
01:00 Brought to you by Sentry.io.
01:33 Why scope your CSS?
03:21 Scott's hot take.
05:43 How does @scope CSS work?
07:31 Similar to a component-based workflow.
08:00 Not having to specify a selector for your scope.
09:52 Pseudo inline hover styles.
11:31 Donut scope.
13:01 "Inverted donut-hole scope"
14:50 Browser support + limitations.
All links available at syntax.fm/729
------------------------------------------------------------------------------
Hit us up on Socials!
Scott: / stolinski
Wes: / wesbos
Randy: / @randyrektor
Syntax: / syntaxfm
www.syntax.fm
Brought to you by Sentry.io
#webdevelopment #webdeveloper #javascript

Пікірлер: 9
@erikslorenz
@erikslorenz 3 ай бұрын
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 3 ай бұрын
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"
@alexandrucomanescu9857
@alexandrucomanescu9857 3 ай бұрын
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 3 ай бұрын
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 3 ай бұрын
So what does @scope do that nested CSS can't?
@syntaxfm
@syntaxfm 3 ай бұрын
Nested css is just simplifying narrowing selectors. @scope allows you to prevent the styles from leaking outside of the scope.
@m12652
@m12652 3 ай бұрын
@@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 3 ай бұрын
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 3 ай бұрын
@@syntaxfm Svelte does rock
How to Code... For beginners
59:37
Syntax
Рет қаралды 3 М.
Svelte 5 is a beast, but is it worth switching?
37:55
Syntax
Рет қаралды 19 М.
Who’s more flexible:💖 or 💚? @milanaroller
00:14
Diana Belitskay
Рет қаралды 19 МЛН
When someone reclines their seat ✈️
00:21
Adam W
Рет қаралды 21 МЛН
Final increíble 😱
00:39
Juan De Dios Pantoja 2
Рет қаралды 41 МЛН
asking questions with..where.when and what?
12:04
Jeandimy
Рет қаралды 75
Keeping up with CSS: The features released in 2023
31:13
Kevin Powell
Рет қаралды 91 М.
11 Habits of Highly Effective Developers
50:50
Syntax
Рет қаралды 3 М.
DejaVue #E010 - Design Patterns in Vue.js
29:39
DejaVue
Рет қаралды 527
Stripe Engineer explains Client Security
1:03:12
Syntax
Рет қаралды 3,1 М.
Host your own Vercel
57:58
Syntax
Рет қаралды 5 М.
Egress, scraping, Safari EU changes, is SetInterval worth it
59:13
Components We Need on Every Project
55:55
Syntax
Рет қаралды 2,8 М.
Who’s more flexible:💖 or 💚? @milanaroller
00:14
Diana Belitskay
Рет қаралды 19 МЛН