Skip to main content

Blazor Theme Switcher

Documentation and examples for using Blazor Bootstrap Theme Switcher components.

Blazor Theme Switcher Component

Parameters

NameTypeDefaultRequiredDescriptionAdded Version
PositionDropdownMenuPositionDropdownMenuPosition.Start✔️Gets or sets the dropdown menu position.3.2.0

Events

EventDescriptionAdded Version
OnThemeChangedFired when the theme is changed.3.2.0

Examples

How it works

Blazor Theme Switcher Component - Examples
<ThemeSwitcher Position="DropdownMenuPosition.End" />

See demo here.

Position

Blazor Theme Switcher Component - Examples
<div class="float-end">
<ThemeSwitcher Position="DropdownMenuPosition.End" />
</div>

See demo here.

Events

Blazor Theme Switcher Component - Examples
<ThemeSwitcher OnThemeChanged="OnThemeChanged" />

@code
{
[Inject]
ToastService ToastService { get; set; } = default!;

private void OnThemeChanged(string themeName)
{
// do something when the theme changes
ToastService.Notify(new(ToastType.Success, $"Theme changed to {themeName}"));
}
}

See demo here.