I've already seen this thread but I follow your code but it doesn't work.
I've created Theme.cs ThemeServices.cs and Modify the MainLayout.cs
I think I have to change something to index.html e.g add the id = "theme" in <link id="theme" rel="stylesheet" href="_content/Radzen.Blazor/css/material-base.css">
and add script in javascript;
Have you any suggestion?
I've point a breakpoint to ChangeTheme and the value selected is good!
The application is blocked when the url: https:/.../?theme=drak (eg)
As far as I know you can't include any Blazor components in index.html - they should either be included in a .cshtml file or .razor file And no, you don't have to copy any CSS theme to wwwroot. Check the getting started instructions how to include a theme CSS file - it shows what the path is. Our online demos is also a WebAssembly applications but it uses prerendering (hence no index.html but _Host.cshtml). You can probably add the theme in MainLayout.razor.
@code{
public const string DefaultTheme = "Software";
public const string QueryParameter = "theme";
public string CurrentTheme { get; set; } = DefaultTheme;
public class Theme
{
public string? Text { get; set; }
public string? Value { get; set; }
}
private List<Theme> Themes = new List<Theme>() {
new Theme(){ Text = "material", Value = "Material" },
new Theme(){ Text = "standard", Value = "Standard" },
new Theme(){ Text = "default", Value = "Default" },
new Theme(){ Text = "dark", Value = "Dark" },
new Theme(){ Text = "humanistic", Value = "Humanistic"},
new Theme(){ Text = "software", Value = "Software" },
};
void ChangeTheme(object value)
{
var url = UriHelper.GetUriWithQueryParameter("theme", $"{value}");
UriHelper.NavigateTo(url, true);
}
}