development-plugin-for-avalonia

FluentTheme Bootstrap, Density, and Palette Customization

Table of Contents

  1. Scope and Primary APIs
  2. Basic Setup
  3. Density
  4. Palette Customization
  5. AOT and Runtime Notes
  6. Do and Don’t Guidance
  7. Troubleshooting
  8. Official Resources

Scope and Primary APIs

Use this reference to configure the Fluent baseline correctly.

Primary APIs:

High-value members:

Basic Setup

<Application xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             RequestedThemeVariant="Default">
  <Application.Styles>
    <FluentTheme DensityStyle="Normal" />
  </Application.Styles>
</Application>

Density

Avalonia 11.3.12 exposes:

using System.Linq;
using Avalonia;
using Avalonia.Themes.Fluent;

var fluent = Application.Current!.Styles.OfType<FluentTheme>().First();
fluent.DensityStyle = DensityStyle.Compact;

Use Compact when:

Palette Customization

<FluentTheme xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <FluentTheme.Palettes>
    <ColorPaletteResources x:Key="Light"
                           Accent="#0F6CBD"
                           BaseHigh="#FF201F1E"
                           ChromeLow="#FFF8F8F8"
                           RegionColor="#FFFFFFFF" />
    <ColorPaletteResources x:Key="Dark"
                           Accent="#4CC2FF"
                           BaseHigh="#FFFFFFFF"
                           ChromeLow="#FF1F1F21"
                           RegionColor="#FF111111" />
  </FluentTheme.Palettes>
</FluentTheme>

Guidance:

AOT and Runtime Notes

Do and Don’t Guidance

Do:

Do not:

Troubleshooting

  1. Palette values appear ignored.
    • Confirm they are inside FluentTheme.Palettes and keyed by Light or Dark.
  2. Compact mode looks broken.
    • The problem is usually custom padding or local styles fighting the base theme.
  3. Light and dark variants feel unrelated.
    • Re-evaluate brand accent intensity and RegionColor / ChromeLow choices together.

Official Resources