Blazor Server - Change Theme Dynamically

Hello, is there a way to dynamically change the theme? The way you do it on your site would be an ideal solution. Is that possible? If so could you provide a sample?

Thank you

Hey @anthonyyott,

You can use the same approach as in our demos - here is the source code:

Thank you. That was very helpful

Can you please update the link? It just points to the github project now.

I could not find anything there, on how to change the theme dynamically.

The link points exactly where it should, the project of our demos where the theme is changed dynamically:

If you care to open the project you will find:

and other useful stuff that might help you to do the same in your own app.

1 Like

Could you tell me where to put (use) the Theme component in a WASM app? I cannot find it in the RadzenBlazorDemos projects.

Hey @Gilberto_Carcano,

Our demos are now WASM app and the themes DropDown is again at the same place:

Hi @enchev, thank you for your quik reply.
The "Theme" component I was talking about is the one defined in radzenhq/radzen-blazor/blob/master/RadzenBlazorDemos/Theme.razor. I didn't see any place where the component is used. For my understanding, this component is the responsible for the effective css changes. I tried to put it at the beginning of MainLayout.razor and it seem to work correctly. Is that the right place?
Thanks in advance.

If you get the entire solution you can easily find what you are looking for:

Thank you, it was exactly what I was searching for!

I save theme into localStorage and then call it from next, but my website always automatic reload, i dont know how?