Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS isolation in blazor-server components

with the new .NET 5 preview CSS isolation comes in blazor. Does anybody know, is it possible to use the CSS isolation in blazor server?

I have play a lot around, but in my blazor server app CSS isolation doesn't work. Or is this feature only available in blazor WebAssembly?

so I tried it:

  • create a new blazor component, e.g. test.razor
  • create component CSS file with name test.razor.css and write the CSS code in this file
  • now start the blazor-server app, but no static CSS file will added and the CSS classes doesn't found.

TargetFramework is "net5.0". installed dotnet version is "5.0.100-rc.2.20479.15".

greetings Daniel

like image 646
Daniel Weber Avatar asked Jan 24 '23 15:01

Daniel Weber


1 Answers

ok i found the issue. In my "_Host.cshtml" file was the link to the "project.styles.css" missing:

<link href="ProjectName.styles.css" rel="stylesheet" />

with this everything works fine.

like image 171
Daniel Weber Avatar answered Mar 29 '23 15:03

Daniel Weber