Jersey Dude
Jersey Dude

Reputation: 607

Is there any way to disable CSS Isolation in Blazor 5.0?

I see the option to DisableScopedCssBundling but do not see a way to disable this feature completely.

Upvotes: 2

Views: 2417

Answers (5)

jcaruso
jcaruso

Reputation: 2494

According to Microsoft there is a way to disable it:

https://learn.microsoft.com/en-us/aspnet/core/blazor/components/css-isolation?view=aspnetcore-5.0#disable-css-isolation

<ScopedCssEnabled>false</ScopedCssEnabled>

Upvotes: 1

lonix
lonix

Reputation: 20489

To disable it completely:

<PropertyGroup>
  <ScopedCssEnabled>false</ScopedCssEnabled>
</PropertyGroup>

To enable it, but disable bundling:

<PropertyGroup>
  <DisableScopedCssBundling>true</DisableScopedCssBundling>
</PropertyGroup>

By the way, to those who commented that it doesn't hurt, and can simply be ignored... I disagree. If there's a feature one doesn't use, which is known to thrash one's disk - it creates many files on every build, and also when using hot reload - then it's a good idea to disable it.

Upvotes: 0

Nikhil Mysore
Nikhil Mysore

Reputation: 283

You can disable this feature by adding the following in csproj file

 <PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<ScopedCssEnabled>false</ScopedCssEnabled>

Add false to disable

Upvotes: 4

Red Wei
Red Wei

Reputation: 942

You can't disable it and you don't need to. If you don't want your CSS to be isolated, you can create a css file and have a <link> tag in your component or just use the <style> tag in your component like it was mentioned here.

Upvotes: -1

rdmptn
rdmptn

Reputation: 5603

I don't think there's a way to disable it, but, on the other hand, you don't need to.

If you don't use it, it will not have effect.

It "works" build-time only, so it won't have overhead for you at runtime.

Upvotes: 4

Related Questions