Theming
Default Light and Default Dark, the 36 color themes from GPUI Kit, the color tokens, the font, and the sizes and variants chosen with style classes.
Color themes
UIKitTheme comes in GPUI Kit's Default Light and Default Dark, which are Avalonia's Light and Dark theme variants, and in the 36 color themes GPUI Kit bundles: Aurora, Ayu, Catppuccin, Gruvbox, Solarized, Tokyo Night and the rest. Choose one with Avalonia's RequestedThemeVariant, on the application, a window or a ThemeVariantScope:
<Application RequestedThemeVariant="Dark">The bundled themes are the theme variants in UIKitThemeVariants. Each is a light or a dark theme and inherits Avalonia's Light or Dark, so what other themes such as FluentTheme define for that mode still applies:
<Application xmlns:uikit="using:AvaloniaUIKit"
RequestedThemeVariant="{x:Static uikit:UIKitThemeVariants.TokyoNight}"><ThemeVariantScope RequestedThemeVariant="{x:Static uikit:UIKitThemeVariants.AuroraLight}">
<Button Classes="primary" Content="Aurora" />
</ThemeVariantScope>In code, UIKitThemeVariants.All lists them, UIKitThemeVariants.Find looks one up by its GPUI Kit name (Default Light and Default Dark too), and UIKitThemeVariants.IsDark tells whether a variant is a dark one:
Application.Current!.RequestedThemeVariant =
UIKitThemeVariants.Find("Catppuccin Mocha") ?? ThemeVariant.Dark;Press T to try them on this site: the site and its live demos take the theme you pick.
| Theme | Mode | Variant |
|---|---|---|
| Adventure | Dark | UIKitThemeVariants.Adventure |
| Adventure Time | Dark | UIKitThemeVariants.AdventureTime |
| Alduin | Dark | UIKitThemeVariants.Alduin |
| Asciinema | Dark | UIKitThemeVariants.Asciinema |
| Aurora Light | Light | UIKitThemeVariants.AuroraLight |
| Ayu Dark | Dark | UIKitThemeVariants.AyuDark |
| Ayu Light | Light | UIKitThemeVariants.AyuLight |
| Catppuccin Frappe | Dark | UIKitThemeVariants.CatppuccinFrappe |
| Catppuccin Latte | Light | UIKitThemeVariants.CatppuccinLatte |
| Catppuccin Macchiato | Dark | UIKitThemeVariants.CatppuccinMacchiato |
| Catppuccin Mocha | Dark | UIKitThemeVariants.CatppuccinMocha |
| Everforest Dark | Dark | UIKitThemeVariants.EverforestDark |
| Everforest Light | Light | UIKitThemeVariants.EverforestLight |
| Fahrenheit | Dark | UIKitThemeVariants.Fahrenheit |
| Flexoki Dark | Dark | UIKitThemeVariants.FlexokiDark |
| Flexoki Light | Light | UIKitThemeVariants.FlexokiLight |
| Gruvbox Dark | Dark | UIKitThemeVariants.GruvboxDark |
| Gruvbox Light | Light | UIKitThemeVariants.GruvboxLight |
| Harper | Dark | UIKitThemeVariants.Harper |
| Hybrid Dark | Dark | UIKitThemeVariants.HybridDark |
| Hybrid Light | Light | UIKitThemeVariants.HybridLight |
| Jellybeans | Dark | UIKitThemeVariants.Jellybeans |
| Kibble | Dark | UIKitThemeVariants.Kibble |
| macOS Classic Dark | Dark | UIKitThemeVariants.MacOSClassicDark |
| macOS Classic Light | Light | UIKitThemeVariants.MacOSClassicLight |
| Mellifluous Dark | Dark | UIKitThemeVariants.MellifluousDark |
| Mellifluous Light | Light | UIKitThemeVariants.MellifluousLight |
| Molokai Dark | Dark | UIKitThemeVariants.MolokaiDark |
| Molokai Light | Light | UIKitThemeVariants.MolokaiLight |
| Solarized Dark | Dark | UIKitThemeVariants.SolarizedDark |
| Solarized Light | Light | UIKitThemeVariants.SolarizedLight |
| Spaceduck | Dark | UIKitThemeVariants.Spaceduck |
| Tokyo Moon | Dark | UIKitThemeVariants.TokyoMoon |
| Tokyo Night | Dark | UIKitThemeVariants.TokyoNight |
| Tokyo Storm | Dark | UIKitThemeVariants.TokyoStorm |
| Twilight | Dark | UIKitThemeVariants.Twilight |
Aurora Light paints buttons, the primary fill, switches, the slider's thumb, progress bars and scrollbar thumbs with gradients, as GPUI Kit does. The other themes are solid colors.
Color tokens
Every color of the theme is a resource with a UIKit. prefix: the base tokens (UIKit.Background, UIKit.Foreground, UIKit.Border, UIKit.Primary, UIKit.PrimaryForeground, UIKit.Secondary, UIKit.Muted, UIKit.MutedForeground, UIKit.Accent, UIKit.Danger, UIKit.Warning, UIKit.Success, UIKit.Info, UIKit.Link, UIKit.Popover, UIKit.FocusRing, the palette colors UIKit.Blue, UIKit.Green and so on) and the colors the components derive from them for their states (UIKit.Button.Primary.Hover.Background, for example). A base token is a solid brush; the Color is the same key with a .Color suffix. Use them with DynamicResource so they follow the theme variant:
<Border Background="{DynamicResource UIKit.Muted}"
BorderBrush="{DynamicResource UIKit.Border}">
<TextBlock Foreground="{DynamicResource UIKit.MutedForeground}" Text="Muted" />
</Border>The tokens a theme may give as a gradient also have a .Fill brush, which is the gradient where the theme has one (UIKit.Primary.Fill is a gradient in Aurora Light, while UIKit.Primary is its first color). Use .Fill for a background that should look like the theme's primary button or switch; the derived background colors are already gradients where the theme's are.
The tokens are generated, so they are not meant to be edited by hand. An application can still override one in Application.Resources, which Avalonia checks before the theme; the derived colors are resources of their own and do not follow the override.
Font
The theme uses the platform's UI font: UIKit.FontFamily is $Default. The demos on this site use Inter; to match them, add Inter to your app and override the resource:
<Application.Resources>
<FontFamily x:Key="UIKit.FontFamily">avares://MyApp/Assets/Fonts#Inter</FontFamily>
</Application.Resources>The other metrics are resources too: UIKit.FontSize (16) with UIKit.FontSize.Xs, .Sm, .Base and .Lg (12, 14, 16, 18), UIKit.Radius (6) and UIKit.RadiusLg (8), and the springs UIKit.Spring.Control and UIKit.Spring.Move that drive the motion.
Sizes
The components come in four sizes. Pick one with a style class; the default is medium.
<Button Classes="xsmall" Content="XSmall" />
<Button Classes="small" Content="Small" />
<Button Content="Medium" />
<Button Classes="large" Content="Large" />Button, SplitButton, DropDownButton, ToggleButton, CheckBox, RadioButton, ToggleSwitch, TextBox, NumericUpDown, ComboBox, AutoCompleteBox, ProgressBar, PathIcon, TabStrip and the new controls take xsmall, small and large.
Variants
Variants are style classes as well, and the classes combine freely:
<Button Classes="primary" Content="Primary" />
<Button Classes="danger outline small" Content="Delete" />
<Button Classes="ghost icon-only">
<PathIcon Data="{StaticResource UIKit.Icon.Copy}" />
</Button>| Control | Classes |
|---|---|
Button | Colors: primary, secondary, danger, warning, success, info, ghost, link, text (none is Default). Modifiers: outline, compact, selected, icon-only. Radius: rounded-none, rounded-small, rounded-large, rounded-full. |
SplitButton | The Button's colors, outline, selected and sizes. |
DropDownButton | The Button's classes. |
ToggleButton, ListBox.toggle-group | outline (ghost is the default); the toggle group also segmented. |
ToggleSwitch | label-left. |
GroupBox | fill, outline (normal is the default). |
Separator | vertical, dashed. |
TabStrip, TabControl | pill, segmented, underline; menu for a button that lists the tabs. |
TextBox | revealPasswordButton, clearButton; group for an input group. |
ComboBox | combobox for the Combobox look; clearButton. |
Image | rounded, rounded-lg, rounded-full. |
uikit:ButtonGroup | The Button's colors, outline and compact, passed to every button. |
uikit:ToggleGroup | outline, segmented. |
uikit:Select | combobox for the Combobox look. |
uikit:ColorSelect | field for an input field instead of the swatch. |
uikit:DateField | plain drops the field's frame and focus ring. |
uikit:Pagination | compact. |
uikit:Alert | info, success, warning, error. |
uikit:TagLabel | primary, secondary, danger, success, warning, info or a palette color (red, blue, emerald…); outline, transparent, fill. |
uikit:Kbd | outline. |
uikit:Skeleton | secondary. |
A class the theme does not know is ignored, so a typo gives the default look rather than an error.
Named themes
A few components are another look of an Avalonia control, chosen with Theme:
<ProgressBar Theme="{StaticResource UIKitSpinner}" IsIndeterminate="True" />
<ProgressBar Theme="{StaticResource UIKitProgressCircle}" Value="60" />
<Expander Theme="{StaticResource UIKitCollapsible}" Header="Details" />
<TableView Theme="{StaticResource UIKitTable}" />