Skip to main content
All docs
V25.1
  • IThemeChangeService Interface

    Allows you to switch between themes at runtime.

    Namespace: DevExpress.Blazor

    Assembly: DevExpress.Blazor.v25.1.dll

    NuGet Package: DevExpress.Blazor

    Declaration

    public interface IThemeChangeService

    Remarks

    The theme change service allows you to switch between multiple themes at runtime. To change an application theme, inject IThemeChangeService with the [Inject] attribute into a Razor page and call the SetTheme(ITheme) method:

    @inject IThemeChangeService ThemeChangeService
    @rendermode InteractiveServer
    
    <DxButton Text="Blazing Berry" Click="() => HandleClick(Themes.BlazingBerry)" />
    <DxButton Text="Fluent" Click="() => HandleClick(Themes.Fluent)" />
    <DxButton Text="Fluent Dark" Click="() => HandleClick(AppThemes.FluentDark)" />
    
    @code {
        void HandleClick(ITheme theme) {
            ThemeChangeService.SetTheme(theme);
            // ...
        }
        public class AppThemes {
            public static ITheme FluentDark = Themes.Fluent.Clone(properties => {
                properties.Name = "FluentDark";
                properties.Mode = ThemeMode.Dark;
            });
            public static List<ITheme> All { get; private set; } = new List<ITheme>() {
                Themes.BlazingBerry,
                Themes.Fluent,
                FluentDark
            };
        }
    }
    
    See Also