Created
June 14, 2022 01:22
-
-
Save kiranmaya/c84a493267e5e47e43127f19d46e4317 to your computer and use it in GitHub Desktop.
Blazor CSS isolation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You have to use "::deep" on CSS that is applied to custom components such as MudBlazor components. Custom components have to be enclosed in a nativ component thus the "<div>". | |
"::deep" CSS does not work on nativ components as it seems. | |
@page "/" | |
<h1>@pageTitle</h1> | |
<div class="mainPaper"> | |
@DateTime.Now.ToLongTimeString() | |
<MudPaper Class="mainPaper" Elevation="8"> | |
<h1>Tesst </h1> | |
@for( int i = 0; i < 2; i++ ) | |
{ | |
<MudText Class="mainPaper">@DateTime.Now.ToLongTimeString()</MudText> | |
<MudText Class="mainPaper">@DateTime.Now.ToLongTimeString()</MudText> | |
} | |
</MudPaper> | |
<MudText Class="mainPaper">@DateTime.Now.ToLongTimeString()</MudText> | |
<MudText Class="mainPaper">@DateTime.Now.ToLongTimeString()</MudText> | |
</div> | |
@code { | |
[Parameter] | |
public string pageTitle { get; set; } = "default"; | |
} | |
//*.razor.css | |
::deep .mainPaper { | |
color: red; | |
background: lightgreen; | |
} | |
.mainPaper { | |
color: red; | |
background: lightgreen; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment