Primary APIs:
TabStrip and TabStripItemSelectingItemsControl selection API (SelectedIndex, SelectedItem, SelectionChanged, SelectionMode)TransitioningContentControl for panel content transitionsContentControl for explicit panel host compositionReference docs:
29-html-css-tabs-offcanvas-and-carousel-shell-patterns.md13-html-css-navigation-tabs-sidebars-breadcrumbs-and-routing-patterns.md10-templated-controls-and-control-themes.md| HTML/CSS idiom | Avalonia mapping |
|---|---|
headless tabs (role="tablist") |
TabStrip |
tab button (role="tab") |
TabStripItem |
selected tab state (aria-selected) |
SelectedIndex / SelectedItem |
| tab panel outlet | ContentControl or TransitioningContentControl |
| segmented control navigation | styled TabStrip |
HTML/CSS baseline:
<nav class="tablist" role="tablist" aria-label="Settings sections">
<button role="tab" aria-selected="true">General</button>
<button role="tab" aria-selected="false">Security</button>
<button role="tab" aria-selected="false">Billing</button>
</nav>
<section class="tabpanel">...</section>
.tablist {
display: inline-flex;
gap: .25rem;
}
.tablist [aria-selected="true"] {
background: #2f6fed;
color: #fff;
}
Avalonia pattern:
<StackPanel Spacing="10">
<TabStrip SelectedIndex="{CompiledBinding SelectedTabIndex, Mode=TwoWay}">
<TabStripItem Content="General" />
<TabStripItem Content="Security" />
<TabStripItem Content="Billing" />
</TabStrip>
<TransitioningContentControl Content="{CompiledBinding CurrentPanelVm}" />
</StackPanel>
HTML/CSS segmented control:
<div class="segmented" role="tablist">
<button role="tab" aria-selected="true">Week</button>
<button role="tab">Month</button>
<button role="tab">Quarter</button>
</div>
Avalonia with TabStrip styling intent:
<TabStrip Classes="segmented"
SelectionChanged="OnRangeTabChanged">
<TabStripItem Content="Week" />
<TabStripItem Content="Month" />
<TabStripItem Content="Quarter" />
</TabStrip>
<section class="settings-shell">
<nav class="tablist" role="tablist">
<button role="tab" aria-selected="true">General</button>
<button role="tab">Integrations</button>
<button role="tab">Security</button>
</nav>
<section class="panel">Current panel content</section>
</section>
.settings-shell {
display: grid;
gap: .75rem;
}
<StackPanel Spacing="12">
<TabStrip SelectedIndex="{CompiledBinding SelectedSettingsTab, Mode=TwoWay}">
<TabStripItem Content="General" />
<TabStripItem Content="Integrations" />
<TabStripItem Content="Security" />
</TabStrip>
<Border BorderBrush="#2A3348" BorderThickness="1" CornerRadius="8" Padding="12">
<TransitioningContentControl Content="{CompiledBinding CurrentSettingsPanelVm}" />
</Border>
</StackPanel>
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
var shell = new StackPanel { Spacing = 12 };
var tabStrip = new TabStrip();
tabStrip.Items.Add(new TabStripItem { Content = "General" });
tabStrip.Items.Add(new TabStripItem { Content = "Integrations" });
tabStrip.Items.Add(new TabStripItem { Content = "Security" });
tabStrip.SelectedIndex = 0;
var panelHost = new TransitioningContentControl
{
Content = new TextBlock { Text = "General settings panel" }
};
tabStrip.SelectionChanged += (_, _) =>
{
panelHost.Content = tabStrip.SelectedIndex switch
{
0 => new TextBlock { Text = "General settings panel" },
1 => new TextBlock { Text = "Integrations panel" },
2 => new TextBlock { Text = "Security panel" },
_ => new TextBlock { Text = "Unknown panel" }
};
};
shell.Children.Add(tabStrip);
shell.Children.Add(new Border
{
BorderBrush = Avalonia.Media.Brushes.Gray,
BorderThickness = new Avalonia.Thickness(1),
Padding = new Avalonia.Thickness(12),
Child = panelHost
});
Dispatcher.UIThread.SelectionChanged to update a content host (ContentControl/TransitioningContentControl).TabStrip styles/class selectors for segmented appearance.TabStrip remains focusable and selection mode is single-select behavior.