Reputation: 379
Do Blazor components support css encapsulation like Angular? If so, how? Else, what is the recommended approach for css per component? I guess encapsulation can still be achieved manually but is there a better support from the framework itself?
Upvotes: 2
Views: 341
Reputation: 108
It has been added to Blazor in .NET 5 with the name: CSS Isolation. You can apply CSS Isolation by naming a CSS file with the same as razor file.
for example, for MainLayout.razor
it's
MainLayout.razor.css
Note: you should place the CSS file in the same folder of the razor file.
It has some issues, for more details read this article.
Upvotes: 0
Reputation: 379
After some searches, it seems like this is a pending feature https://github.com/aspnet/AspNetCore/issues/10170
but there seem to be a library as a workaround https://github.com/alexandrereyes/BlazorScopedCss
Upvotes: 2