Daniel Weber
Daniel Weber

Reputation: 191

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:

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

greetings Daniel

Upvotes: 7

Views: 4502

Answers (2)

Angel Del Rosario
Angel Del Rosario

Reputation: 11

If you are using .NET 6.0 blazor server side, paste the following line:

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

On the Pages > _Layout.cshtml file and it will work as expected.

Upvotes: 1

Daniel Weber
Daniel Weber

Reputation: 191

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.

Upvotes: 12

Related Questions