index.html

sblb 1,231 Reputation points
2023-07-23T17:10:32.11+00:00

Hi,

I've created ThemeService.cs to change the rendering place in dropdown box in MainLayout.razor

the theme that is always used is the one in the index.html.

How I can link the ThemeService.cs and index.html or use only the theme that I defined?

Thanks in advance

Developer technologies .NET Blazor
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2023-07-23T17:36:29.5133333+00:00

    The theme is just a css file. When you choose a new theme you will load a new css file. The css theme files should be designed to override the original theme as that css file is still loaded.

    Your other option is when a new theme is chosen, you reload the blazor app via location.reload() and pass the themeid as a query string parameter. This probably the most common website approach as the style tree will be smaller and faster.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.