AvaloniaThemeManager provides a complete theming solution for Avalonia UI applications. Features include multiple built-in themes (Dark, Light, Ocean Blue, Forest Green, Purple Haze, High Contrast, Cyberpunk), dynamic theme switching with persistence, comprehensive control styling, and easy integration via extension methods.
$ dotnet add package AvaloniaSkinManagerA comprehensive theme management library for Avalonia UI applications with multiple built-in themes, dynamic theme switching, and extensive control styling.
Install via NuGet Package Manager:
dotnet add package AvaloniaThemeManager
Or via Package Manager Console:
Install-Package AvaloniaThemeManager
using Avalonia;
using AvaloniaThemeManager.Extensions;
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.UseThemeManager() // Add this line
.LogToTrace()
.UseReactiveUI();
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="YourApp.App">
<Application.Resources>
<ResourceDictionary>
<!-- Include the skin manager ControlTheme resources -->
<ResourceInclude Source="avares://AvaloniaThemeManager/Themes/CustomThemes.axaml" />
</ResourceDictionary>
<Application.Styles>
<FluentTheme />
<!-- Include AvaloniaThemeManager styles -->
</Application.Styles>
</Application>
using AvaloniaThemeManager.Theme;
// Switch to a different theme
SkinManager.Instance.ApplySkin("Dark");
SkinManager.Instance.ApplySkin("Ocean Blue");
SkinManager.Instance.ApplySkin("Cyberpunk");
// Get available themes
var availableThemes = SkinManager.Instance.GetAvailableSkinNames();
// Listen for theme changes
SkinManager.Instance.SkinChanged += (sender, args) =>
{
Console.WriteLine("Theme changed!");
};
| Theme Name | Description | Preview |
|---|---|---|
| Dark | Professional dark theme with blue accents | |
| Light | Clean light theme perfect for bright environments | |
| Ocean Blue | Deep blue theme inspired by ocean depths | |
| Forest Green | Nature-inspired green theme | |
| Purple Haze | Rich purple theme with mystical vibes | |
| High Contrast | Maximum contrast for accessibility | |
| Cyberpunk | Futuristic neon theme with hot pink accents |
<UserControl xmlns:controls="clr-namespace:AvaloniaThemeManager.Controls;assembly=AvaloniaThemeManager">
<StackPanel>
<!-- Quick theme switcher dropdown -->
<controls:QuickThemeSwitcher />
<!-- Your other UI elements -->
<Button Content="Sample Button" />
<TextBox Watermark="Sample TextBox" />
</StackPanel>
</UserControl>
using AvaloniaThemeManager.Views;
private async void OpenThemeSettings()
{
var dialog = new ThemeSettingsDialog();
await dialog.ShowDialog(this); // 'this' is your parent window
}
using AvaloniaThemeManager.Theme;
using Avalonia.Media;
// Create a custom theme
var customTheme = new Skin
{
Name = "My Custom Theme",
PrimaryColor = Color.Parse("#FF6B6B"),
SecondaryColor = Color.Parse("#4ECDC4"),
AccentColor = Color.Parse("#45B7D1"),
PrimaryBackground = Color.Parse("#2C3E50"),
SecondaryBackground = Color.Parse("#34495E"),
PrimaryTextColor = Color.Parse("#FFFFFF"),
SecondaryTextColor = Color.Parse("#BDC3C7"),
BorderColor = Color.Parse("#7F8C8D"),
ErrorColor = Color.Parse("#E74C3C"),
WarningColor = Color.Parse("#F39C12"),
SuccessColor = Color.Parse("#2ECC71")
};
// Register and apply the custom theme
SkinManager.Instance.RegisterSkin("Custom", customTheme);
SkinManager.Instance.ApplySkin("Custom");
// Configure theme manager during startup
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.UseThemeManager(manager =>
{
// Register custom themes
manager.RegisterSkin("Corporate", corporateTheme);
// Set default theme
manager.ApplySkin("Dark");
})
.LogToTrace()
.UseReactiveUI();
using AvaloniaThemeManager.ViewModels;
public class MainWindowViewModel : ViewModelBase
{
public ThemeSettingsViewModel ThemeSettings { get; }
public MainWindowViewModel()
{
ThemeSettings = new ThemeSettingsViewModel();
}
}
<Window xmlns:vm="clr-namespace:AvaloniaThemeManager.ViewModels;assembly=AvaloniaThemeManager">
<ComboBox ItemsSource="{Binding ThemeSettings.AvailableThemes}"
SelectedItem="{Binding ThemeSettings.SelectedTheme}">
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Spacing="8">
<Ellipse Width="12" Height="12" Fill="{Binding PreviewColor}" />
<TextBlock Text="{Binding Name}" />
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</Window>
AvaloniaThemeManager provides comprehensive styling for:
Theme preferences are automatically saved to:
%LocalAppData%/ResumeForge/appsettings.json~/Library/Application Support/ResumeForge/appsettings.json~/.local/share/ResumeForge/appsettings.jsonContributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
Skin object with your color schemeSkinManager.RegisterDefaultSkins()GetThemeDescription() methodThis project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ for the Avalonia UI community