How can I set up material light and dark mode in a MAUI or Blazor standalone app?

Hi!

I saw that version 5.0.0 has been released, but I couldn't find any documentation on how to set it up in a Blazor application that has an index.html file.

I would like some help with this if possible, with an example code.
Thank you.

There isn't an easy way to dynamically change css files with index.html or render a Blazor component. You can try using RadzenTheme in your layout instead.

In theory with HeadContent its posible to change css, but then RadzenTheme its overwriting custom css rules. As a workaround i can add other css rules in headcontent, but would be nice to have a better solution to Blazor standalone wasm.

Probably adding RadzenTheme there would work (still has to be done in the MainLayout). You can test that.

RadzenTheme only renders a <link> element pointing to the current theme. It is not overwriting any custom CSS rules.

1 Like

Thank you, it works with HeadContent.

1 Like

Hi Igor,

Can you go into detail on what you did exactly to solve this?

Thanks,

Vincent

Hi Vincent,

Example code:

The modified files are index.html, MainLayout.razor, MainPage.xaml.

1 Like