Smart UI Components & Libraries – Grid, Scheduler, Gantt, Kanban for Angular, React, Next.js, Vue, Blazor, JavaScript › Forums › Editor & Inputs › css on blazor componet not applying
- This topic has 2 replies, 2 voices, and was last updated 3 years ago by
Patrick Hume.
-
AuthorPosts
-
November 18, 2022 at 11:10 pm #104006
Patrick Hume
Participantso if I have a smart bazlor control on a blazor razor page say “Foo.razor” and my css for that smart blazor control in “Foo.razor.css” the css will apply so long as I add “::deep smart-some-contol” to the css that I want to apply to the smart blazor control however if I have the smart bazlor control on a component razor page that’s loaded in my page the css no longer applies regardless of if I put it in the parent page css or child component css and only works if i put it in the global app css but I don’t want to have to do that, I tried using ::shawdo but that didn’t work, what’s the correct css to get the css to apply to the child page component?
parent:
Foo.razor
Foo.razor.csssome html <bar />
child component:
bar.razor
bar.razor.cssthanks
-
This topic was modified 3 years ago by
Patrick Hume.
November 22, 2022 at 10:13 pm #104011ivanpeevski
ParticipantHi Patrick,
The Blazor CSS Isolation works by attaching a random attribute to the HTML element that works as a selector. However, our controls are generated dynamically and then selector key is lost. The trick is to wrap the blazor controls in a normal HTML element such as div, span or p. In this way, the selector key will be attached to the wrapper HTML and the inner controls will remain selectable. For example:
parent.razor:
<Child/>
child.razor:
<div><Button>Test</Button></div>
child.razor.css:
::deep smart-button {
background: red;
}OR(if you wish to be more specific):
div ::deep smart-button {
background: red;
}This creates a red button. I hope this was of help!
Please feel free to contact us again, if you need further support
Best Regards,
Ivan PeevskiSmart UI Team
https://www.htmlelements.com/-
This reply was modified 3 years ago by
ivanpeevski.
-
This reply was modified 3 years ago by
ivanpeevski.
November 22, 2022 at 11:18 pm #104017Patrick Hume
Participantah I see, thank you that helps explain it, I understand why it wasn’t working now, 🙂
-
This topic was modified 3 years ago by
-
AuthorPosts
- You must be logged in to reply to this topic.