Adding class isolated style on blazor component
-
Hi, I am trying to add a style class to a blazor component, with isolated style method and when I add the style class on the blazor component located in the index.razor file, the blazor component disapears. I am doing that on a Webassembly Blazor project. So: I have followig files: -Index.razor, where I want to display the razor component
@page "/"
Index
Hello, world!
Welcome to your new app.
-DisplayComponent.razor, where the component is defined
DisplayComponent
how cool, it works
-DisplayComponent.razor.css where the style class is defined
.displayStyle{
margin:7px;
}So please help me understading and implement this concept of isolated style. When I add class="displayStyle" on the display component in index.razor the content of the "DisplayComponent" disappear. I keep testing but I can't manage implementing a class on a blazor component with isolating style metgod. Give me some sugestions please. What I am missing? Thank you.
-
Hi, I am trying to add a style class to a blazor component, with isolated style method and when I add the style class on the blazor component located in the index.razor file, the blazor component disapears. I am doing that on a Webassembly Blazor project. So: I have followig files: -Index.razor, where I want to display the razor component
@page "/"
Index
Hello, world!
Welcome to your new app.
-DisplayComponent.razor, where the component is defined
DisplayComponent
how cool, it works
-DisplayComponent.razor.css where the style class is defined
.displayStyle{
margin:7px;
}So please help me understading and implement this concept of isolated style. When I add class="displayStyle" on the display component in index.razor the content of the "DisplayComponent" disappear. I keep testing but I can't manage implementing a class on a blazor component with isolating style metgod. Give me some sugestions please. What I am missing? Thank you.
-
Hi, I am trying to add a style class to a blazor component, with isolated style method and when I add the style class on the blazor component located in the index.razor file, the blazor component disapears. I am doing that on a Webassembly Blazor project. So: I have followig files: -Index.razor, where I want to display the razor component
@page "/"
Index
Hello, world!
Welcome to your new app.
-DisplayComponent.razor, where the component is defined
DisplayComponent
how cool, it works
-DisplayComponent.razor.css where the style class is defined
.displayStyle{
margin:7px;
}So please help me understading and implement this concept of isolated style. When I add class="displayStyle" on the display component in index.razor the content of the "DisplayComponent" disappear. I keep testing but I can't manage implementing a class on a blazor component with isolating style metgod. Give me some sugestions please. What I am missing? Thank you.
To use isolated styles correctly: In DisplayComponent.razor, apply the class directly:
DisplayComponent
How cool, it works
In Index.razor, remove the class from the wrapping
:
that's how the component will display with the styles applied correctly.