Search code examples
xamlavaloniaui

How to define a separate set of styles for each platform/OS in Avalonia?


Is there a way to apply different styles depending on the operation system? How does one define separate themes for Windows, macOS and Linux?


Solution

  • There is currently only one "default" theme, platform-specific themes are planned, but not yet implemented.

    If you want per-platform themes/styles, you need to add them to your Application.Styles manually inside Application.Initialize using StyleInclude class (See App.xaml from application template). For platform detection you can use AvaloniaLocator.Current.GetService<IRuntimePlatform>().GetRuntimeInfo().OperatingSystem.