-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Css in isolated files do not apply. #591
Comments
It can be related to your project. It's created on .net 5 or upgraded from net core 3.x ? On my last project creation, the css declared link was changed to: I have some projects upgraded from .net core 3.x that don't work with CSS isolation. |
My project has initially been created with .Net 5. |
@porkopek do you know a solution to this? |
Hard to tell without seeing the code, but maybe is specificity related
that is more specific than your rule |
Important does not help, when I do in with Style="...", it works fine, also when I add the same style with html <style></style> tag, it works. |
@aspramsh please could you post what you have in head on your index.html page |
|
I keep thinking this is a specificity thing, that's because with Style works.
|
At this line:
Keep in mind that the "ProjectName" must match our project's name. It's just an example when I wrote this on trying to help you. Real example, on a project called "CAE.Server":
|
Sure, it is okay, CSS isolation works for other components for example |
|
Tried here and can't get it working either on MudButton, but if I change the last attribute on MudButton manually it works: To: ================== By the moment, I suggest you use MudThemeProvider and customize the colors. |
This could shed more light on this issue |
@porkopek do you fully understand the problem now? I read it but I didn't get it ;) |
Nevermind, I got it now after your explanation on gitter:
|
The problem of the OP I can't be sure what it is, because she didn't answer to the questions I make her, nor show us all the code, but what I learnt from this issue is that if you have a component from an external library and it is used outside of scope of the isolation, it won't work, so you need to wrap it in a For If you have a page like
a component Table.razor that is like
the
What the isolation produces is something like
but your component Table doesn't have the However, if you wrap it in a
The blazor/razor engine gives to this
|
In this case the rule gets applied to the div, but I need to override mud-blazor styles. For example I would like to have nav-items text in white, here is my CSS
This does not work in NavMenu.razor.css file, when I put navigation component, b-5fjnqwri5o applies to my div element, but the |
Please, show us the markup. |
Please try this:
|
@HClausing that helped, thank you. |
1 similar comment
@HClausing that helped, thank you. |
I know @Garderoben thinks our documentation should not be a "How-To-Blazor-Wiki" but I would make an exception for this and document it (i.e. under Customization) for future reference because I have seen it comes up many times on the chat and we can then simply post the url of the page. |
I discovered a similar question on Stackoverflow and answered with what I learned from you guys. Hope it is all correct, if not, please let me know. |
Enlightening others could never be wrong :-) |
I use MudButton. I would like to customize for example text color, when I do it with Style attribute or write it in
app.css everything works just fine. But when I move the styling to my component's .css it does not work. Here is my style
.mud-button-text { color: black; }
Actually when I change MutButton to a common button CSS isolation works just fine.
The text was updated successfully, but these errors were encountered: