Skip to content
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

add new css root variable as mud attribute #17

Open
saberpooyan opened this issue Jan 26, 2023 · 3 comments
Open

add new css root variable as mud attribute #17

saberpooyan opened this issue Jan 26, 2023 · 3 comments

Comments

@saberpooyan
Copy link

saberpooyan commented Jan 26, 2023

Hi i'm going to add some property attributes to mud palette so I created new class as you can see in the picture:
Capture1
and then I used that in PresetThemes.cs class like this
Capture2
Now as a result I can see my property in c# code but I can't use it as a CSS variable like this var(--mud-palette-ForegroundColor).
How can i solve this problem?

@henon
Copy link
Collaborator

henon commented Jan 26, 2023

@Garderoben @JonBunator ?

@JonBunator
Copy link
Member

JonBunator commented Jan 26, 2023

This won't work because MudTheme requires the more generic Palette class. You can override the theme provider instead:

public class MyOwnThemeProvider : MudThemeProvider
{
    protected override void GenerateTheme(StringBuilder theme)
    {
        base.GenerateTheme(theme);

        if(base.IsDarkMode == true)
        {
            theme.AppendLine($"--mud-palette-ForegroundColor {new MudColor("#dd5858")};");
        }
        else
        {
            theme.AppendLine($"--mud-palette-ForegroundColor: red;");
        }
    }
}

But imo it should be possible to add custom variables without overriding the theme provider. See MudBlazor/MudBlazor#6148

@saberpooyan
Copy link
Author

Thank you for your guidance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants