Explain how CSS Isolation works in Blazor. What does the ::deep combinator do?
Last updated
A
.razor.cssfile next to a component scopes its styles: Blazor stamps a unique attribute (e.g.b-abc123) on the component's elements and rewrites selectors to match it.All scoped rules are bundled into one
{Project}.styles.cssfile. Styles apply only to the component's own markup, not to child components.The
::deepcombinator lets a scoped rule reach descendants (e.g.ChildContentor child component markup) by applying the scope attribute to the ancestor only.
- https://learn.microsoft.com/en-us/aspnet/core/blazor/components/css-isolation?view=aspnetcore-10.0
- https://docs.devexpress.com/Blazor/404361/styling-and-themes/css-isolation
- https://daily.dev/posts/blazor-s-css-isolation-deep-issue-and-solution-lzbjr6afr
- https://khalidabuhakmeh.com/posts/blazors-css-isolation-deep-issue-and-solution/
- https://jonathancrozier.com/blog/styling-blazor-child-components-with-css-isolation-what-you-really-need-to-know
- https://code-maze.com/css-isolation-in-blazor-applications/