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

Not able to change primary text color. #1674

Closed
kunalpgithub opened this issue Jan 7, 2021 · 11 comments
Closed

Not able to change primary text color. #1674

kunalpgithub opened this issue Jan 7, 2021 · 11 comments
Labels
Type: Bug 🐞 Something isn't working
Projects
Milestone

Comments

@kunalpgithub
Copy link

kunalpgithub commented Jan 7, 2021

I want to change text color of my heading in blazorise component using theme.

It looks like colors are getting override by boostrap mixing scss.

Here is my code for theme and usage of heading component.

<Blazorise.ThemeProvider Theme="@theme">
    <Router AppAssembly="@typeof(Program).Assembly">
        <Found Context="routeData">
            <RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
        </Found>
        <NotFound>
            <LayoutView Layout="@typeof(MainLayout)">
                <p>Sorry, there's nothing at this address.</p>
            </LayoutView>
        </NotFound>
    </Router>
</Blazorise.ThemeProvider>

@code{

    private Theme theme = new Theme
    {
        
        BackgroundOptions = new ThemeBackgroundOptions {
            Primary = "#212336",
            // #FF4A57
        },

        TextColorOptions = new ThemeTextColorOptions {
            Primary = "#FF4A57",
        },
        
    };
}

Here is usage of my theme colors


<Heading Size="HeadingSize.Is1" Color="TextColor.Primary" >
        Skill Sets
    </Heading>

But in browser I don't see this color getting applied, instead if picks up default primary blue color.

image

I would like to see color applied in theme variable instead of default.

I have also tried overriding class in component css and in global css file, but still its picking default blue color.

Let me know if I am doing anything wrong.

@stsrki
Copy link
Collaborator

stsrki commented Jan 7, 2021

It seems like a missing !important flag. Should be an easy fix.

@stsrki stsrki added the Type: Bug 🐞 Something isn't working label Jan 7, 2021
@stsrki stsrki added this to 🔙 Backlog in Support via automation Jan 7, 2021
@stsrki stsrki added this to the 0.9.2 milestone Jan 7, 2021
@kunalpgithub
Copy link
Author

Tried adding important as well, but its not working. Do you mean to add important in theme class, that is also not working.

    private Theme theme = new Theme
    {
        
        BackgroundOptions = new ThemeBackgroundOptions {
            Primary = "#212336",
            // #FF4A57
        },

        TextColorOptions = new ThemeTextColorOptions {
            Primary = "#FF4A57 !important",
        },
        
    };

@stsrki
Copy link
Collaborator

stsrki commented Jan 7, 2021

Adding it there would not work. It needs to be built with ThemeGenerator.

@kunalpgithub
Copy link
Author

is there good document around it, on how to use theme generator?

@stsrki
Copy link
Collaborator

stsrki commented Jan 7, 2021

ThemeGenerator is not something to be used directly. It is an internal builder that creates CSS styles based on the Theme options. Every Blazorise provider has its own theme generator with its own rules.

@wflouw
Copy link

wflouw commented Jan 10, 2021

Having the exact same issue. I implemented a Theme using the ThemeProvider as explained in the documentation. I set the Primary value for the TextColorOptions and I get the same behaviour as @kunalpgithub.

private Theme CustomTheme = new Theme
{
    ColorOptions = new ThemeColorOptions
    {
        Primary = ThemeColors.Red.Shades["400"].Value,
        Secondary = ThemeColors.Blue.Shades["400"].Value
    },
    BackgroundOptions = new ThemeBackgroundOptions
    {
        Primary = ThemeColors.Red.Shades["400"].Value,
        Secondary = ThemeColors.Blue.Shades["400"].Value
    },
    TextColorOptions = new ThemeTextColorOptions
    {
        Primary = ThemeColors.Orange.Shades["400"].Value,
        Secondary = ThemeColors.Yellow.Shades["400"].Value
    }
};

I check the values in the developer console (Chrome) and I can clearly see that the value I defined in the ThemeTextColorOptions is correct but is striked through and overridden by the default value.

image

I could solve the issue by adding the !important value in my app.css but it feels dirty and I think it should work via the the ThemeProvider as described in the documentation.

.text-primary {
    color: #FFA726 !important;
}

@kunalpgithub
Copy link
Author

kunalpgithub commented Jan 11, 2021

@wflouw in my case, even important is also not working. Difference I see is , you are using material and I am using bootstrap.

@nvassell
Copy link

@stsrki How should we include the !important in the theme CSS? I can't get the important tag.

@kunalpgithub
Copy link
Author

@nvassell adding style in my index.html with important worked for me. You can try that.

 <style>
        .text-primary {
            color: #FF4A57 !important;
        }
        .nav-link {
            color: #FDFDFD !important;
        }
    </style>

@nvassell
Copy link

@kunalpgithub Oh interesting! I haven't tried that yet!

@stsrki
Copy link
Collaborator

stsrki commented Jan 12, 2021

@nvassell As a workaround use the @kunalpgithub example. In the meantime, I will fix it in the code.

@stsrki stsrki closed this as completed Jan 12, 2021
Support automation moved this from 🔙 Backlog to ✔ Done Jan 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug 🐞 Something isn't working
Projects
Support
  
✔ Done
Development

No branches or pull requests

4 participants