Tabs & accordion

TabControl · TabStripControl · AccordionControl

Three ways to show one section at a time: tabs with their own panes, a bare tab strip you wire up yourself, and stacked headers that expand.

Overview

TabControl owns its content: each TabItem declares a header and a pane, and SelectedIndex binds two ways. TabStripControl is the header row alone, driven by a list of TabStripItems with icons, disabled and closable tabs, for cases where the content lives elsewhere, such as open documents or routes. AccordionControl stacks AccordionItemControl headers and expands one at a time, or several with Multiple.

Examples

#Tab control

Panes are declared inline; only the selected one renders, so the Lines table is not in the page until its tab is chosen. The TabItems wrapper is optional.

Example
Razor
C#
Estimate
EST-2042 Contoso kitchen
Status
Draft, 14 lines
Total
$12,480

Tab 1 of 3 selected

#Tab strip

The strip renders headers only; the page shows the selected item's Tag underneath. Closable tabs raise OnTabClose with the index and the page removes the item. A disabled tab ignores clicks.

Example
Razor
C#
Estimate×
Drawings×
Photos×
Invoice
EST-2042 Contoso kitchen, 14 lines, draft.
4 open, 0 closed

#Accordion

Multiple="true" lets several sections stay open; without it, opening one closes the rest. InitiallyExpanded opens a section on first render and Disabled greys its header.

Example
Razor
Contoso Ltd, account 10420, net 30.

Documentation

TabControl parameters

ParameterTypeDefaultDescription
SelectedIndexint0Index of the visible pane. Two-way with @bind-SelectedIndex.
SelectedIndexChangedEventCallback<int>—Fires when a different header is clicked.
ChildContentRenderFragment?—TabItems, optionally inside a TabItems wrapper. Order follows declaration.
CssClassstring?nullAppended to the fx-tabs root. There is no Style; this control does not derive from FlexControlBase.

TabItem parameters

ParameterTypeDefaultDescription
HeaderTextstring""Header button label.
ContentRenderFragment?nullPane markup; takes precedence over child content.
ChildContentRenderFragment?nullPane markup when Content is not set.

TabStripControl parameters

ParameterTypeDefaultDescription
ItemsList<TabStripItem>emptyTabs, in order.
SelectedIndexint0Active tab. Two-way with @bind-SelectedIndex. Not clamped when items are removed; clamp it yourself.
SelectedIndexChangedEventCallback<int>—Fires on a click on an enabled tab.
OnTabCloseEventCallback<int>—Fires with the index when a closable tab's × is clicked. The strip does not remove the item.
CssClassstring?nullAppended to the fx-tabstrip root. Not a FlexControlBase control.

TabStripItem

PropertyTypeDefaultDescription
Textstring""Label.
IconCssstring?nullLeading icon classes.
ClosableboolfalseShows the × button.
DisabledboolfalseGreys the tab and ignores clicks.
Tagobject?nullAnything the page wants to carry with the tab.
ctor—new(text, iconCss, closable) or an object initialiser.

AccordionControl parameters

ParameterTypeDefaultDescription
Multipleboolfalsetrue keeps several items open; false closes the others when one opens.
ChildContentRenderFragment?—AccordionItemControls.
CssClass / Style (base)string?nullOn the fx-accordion root.

AccordionItemControl parameters

ParameterTypeDefaultDescription
Titlestring?nullHeader text when HeaderContent is not set.
IconCssstring?nullIcon before the title.
DisabledboolfalseDisables the header button.
InitiallyExpandedboolfalseOpen on first render. In single mode the last such item wins.
HeaderContentRenderFragment?nullReplaces icon and title inside the header button; the arrow stays.
ChildContentRenderFragment?nullBody, rendered only while expanded.
Expanded (read-only)bool—Current state, asked of the parent.

CSS classes

ClassEffect
fx-tabs · fx-tab-headers · fx-tab-button (.active) · fx-tab-contentTab control root, header row, header buttons and the bordered pane.
fx-tabstrip · fx-tabstrip-tab (-active, -disabled) · fx-tabstrip-icon · fx-tabstrip-text · fx-tabstrip-closeStrip row with a bottom border, each tab with a 2px active underline, its icon, text and × button.
fx-accordion · fx-accordion-item (.fx-accordion-expanded, .fx-accordion-disabled)Rounded bordered stack and each item; the expanded class rotates the arrow.
fx-accordion-header · -icon · -title · -arrow · -bodyHeader button and its parts; the body carries the padding.

CSS variables (TabStripControl only)

VariableFallbackPurpose
--fx-tab-bg · --fx-tab-color · --fx-text-color#f9fafb · #6b7280 · #1f2937Strip background, resting and hover text.
--fx-tab-active-color · --fx-tab-active-border-color · --fx-tab-active-bg#1b6ec2 · #1b6ec2 · transparentActive tab text, underline and fill.
--fx-border-color · --fx-sidebar-item-hover-bg · --fx-text-muted#e5e7eb · #f3f4f6 · #d1d5dbStrip bottom border, hover fill, disabled text.
--fx-font-size · --fx-zoom13px · 1Tab font size and zoom factor.
(none)—TabControl and the accordion read no variables; their colours are fixed in the stylesheets.

Keyboard and accessibility

  • TabControl headers are native buttons: Tab moves between them and Enter or Space selects. There are no tablist, tab or tabpanel roles and no arrow-key handling.
  • TabStripControl tabs are <div>s with click handlers only; they are not keyboard-focusable. Use TabControl where keyboard access matters.
  • Each accordion header is a button with aria-expanded; the body is a role="region". A disabled header is a disabled button.
An unhandled error has occurred. Reload 🗙

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.