Use this reference to establish readable hierarchy and polished content rhythm.
Primary APIs:
TextBlock, SelectableTextBlockTextElement.FontFamily, FontWeight, FontStyleTextBlock.TextWrapping, TextBlock.TextTrimming, TextBlock.TextAlignmentAppBuilder.ConfigureFonts(...), WithInterFont()PathIconAutomationProperties.NameUse a small role system:
Example:
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style Selector="TextBlock.eyebrow">
<Setter Property="FontSize" Value="12" />
<Setter Property="FontWeight" Value="SemiBold" />
<Setter Property="Foreground" Value="{DynamicResource Brush.Text.Secondary}" />
</Style>
<Style Selector="TextBlock.title">
<Setter Property="FontSize" Value="22" />
<Setter Property="FontWeight" Value="SemiBold" />
<Setter Property="Foreground" Value="{DynamicResource Brush.Text.Primary}" />
</Style>
<Style Selector="TextBlock.body">
<Setter Property="FontSize" Value="14" />
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="Foreground" Value="{DynamicResource Brush.Text.Primary}" />
</Style>
<Style Selector="TextBlock.meta">
<Setter Property="FontSize" Value="12" />
<Setter Property="TextTrimming" Value="CharacterEllipsis" />
<Setter Property="Foreground" Value="{DynamicResource Brush.Text.Secondary}" />
</Style>
</Styles>
Cross-platform defaults:
WithInterFont() or custom font setup when a product-wide consistent tone matters,public static AppBuilder BuildAvaloniaApp() =>
AppBuilder.Configure<App>()
.UsePlatformDetect()
.WithInterFont();
Use PathIcon for vector icons that should inherit text color and scale predictably.
<StackPanel xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Orientation="Horizontal"
Spacing="8">
<PathIcon Data="{StaticResource Icon.Search}" />
<TextBlock Classes="body" Text="Search incidents" />
</StackPanel>
Guidance:
Do:
Do not: