The tab a page opens on, unless the URL names another.
Mounted at 3:03:24 PM
Tabs divides a page into tabs, each a TabPanel named by its Value (value in React), the same on Blazor and React. It can keep the selected tab in the URL, so a page opens on it again, and it mounts each panel only when it is first shown.
<Tabs>
<TabPanel value="overview" header="Overview">...</TabPanel>
<TabPanel value="contacts" header="Contacts">...</TabPanel>
<TabPanel value="documents" header="Documents">...</TabPanel>
</Tabs><Tabs>
<TabPanel Value="overview" Header="Overview">...</TabPanel>
<TabPanel Value="contacts" Header="Contacts">...</TabPanel>
<TabPanel Value="documents" Header="Documents">...</TabPanel>
</Tabs>Set SelectedTabQueryParameter (selectedTabQueryParameter in React) to keep the selected tab in that query-string parameter. A refresh, a shared link or coming back to the page then opens it on that tab. Choosing a tab replaces the browser's history entry rather than adding one, so the back button leaves the page instead of stepping through its tabs, and a form's unsaved-changes warning doesn't come up for it. The default tab is left out of the URL. Tabs are named by value, not position, so a link still opens the right tab after tabs are added or moved. Give each set of tabs on a page its own parameter.
{/* The selected tab is kept in ?tab=, and the page opens on it again */}
<Tabs selectedTabQueryParameter="tab">
...
</Tabs><!-- The selected tab is kept in ?tab=, and the page opens on it again -->
<Tabs SelectedTabQueryParameter="tab">
...
</Tabs>A panel mounts the first time its tab is shown and then stays mounted, so a grid on it isn't loaded until it is wanted, and doesn't load again, or lose its page and search, when the user comes back to it. A panel's editors aren't part of the form until it mounts, so mount a panel of a form's fields with the tabs: set LazyMount (lazyMount in React) to false on that TabPanel, and the form validates and saves them before the tab is opened. Set it on Tabs to mount every panel with the tabs.
Bind SelectedTab (selectedTab and onSelectedTabChange in React) to know which tab is selected or to select one. DefaultTab (defaultTab) is selected when nothing else selects one; otherwise it's the first tab that isn't disabled. A tab named by the URL is selected over both when the page opens.
<Tabs selectedTab={tab} onSelectedTabChange={setTab} defaultTab="contacts">
...
</Tabs>
<Button onClick={() => setTab('documents')}>Show documents</Button><Tabs @bind-SelectedTab="_tab" DefaultTab="contacts">
...
</Tabs>
<FluentButton OnClick="@(() => _tab = "documents")">Show documents</FluentButton>Each panel shows when it was mounted: switch back and forth and the time stays, because a panel stays mounted. The selected tab is kept in the URL's tab parameter, so refreshing the page opens it again. The last tab is disabled.
The tab a page opens on, unless the URL names another.
Mounted at 3:03:24 PM
Name | Type | Default | Description |
|---|---|---|---|
ChildContent | RenderFragment? | The tabs: a Components.TabPanel for each. | |
DefaultTab | string? | The TabPanel.Value of the tab selected when nothing else selects one; the first tab that isn't disabled when null. It is left out of the URL. | |
LazyMount | bool | True | Whether a panel mounts only when it is first shown (the default), and then stays mounted. When false every panel mounts with the tabs. A panel's own TabPanel.LazyMount overrides it. |
SelectedTab | string? | The TabPanel.Value of the selected tab. Bind it to know which is selected or to select one. A tab named by the URL is selected over it when the page opens. | |
SelectedTabQueryParameter | string? | The query-string parameter that keeps the selected tab in the URL, as a grid's null (the default) the selection isn't kept. Give each set of tabs on a page its own. |
ChildContentComponents.TabPanel for each.DefaultTabTabPanel.Value of the tab selected when nothing else selects one; the first tab that isn't disabled when null. It is left out of the URL.LazyMountfalse every panel mounts with the tabs. A panel's own TabPanel.LazyMount overrides it.SelectedTabTabPanel.Value of the selected tab. Bind it to know which is selected or to select one. A tab named by the URL is selected over it when the page opens.SelectedTabQueryParameternull (the default) the selection isn't kept. Give each set of tabs on a page its own.Name | Type | Description |
|---|---|---|
SelectedTabChanged | EventCallback<string> | Raised when another tab is selected, with its TabPanel.Value. |
SelectedTabChangedTabPanel.Value.Name | Type | Default | Description |
|---|---|---|---|
ChildContent | RenderFragment? | The panel's content. | |
Disabled | bool | False | Whether the tab can't be selected. |
Header | string? | The tab's header text. | |
HeaderTemplate | RenderFragment? | The tab's header, in place of TabPanel.Header. | |
LazyMount | bool? | Whether the panel mounts only when it is first shown, overriding Tabs.LazyMount. Mount a panel of a form's editors with the tabs (false), so the form validates and saves the fields on it before it is opened. | |
Value* | string | Names the tab: what Tabs.SelectedTab holds and the URL carries. A short name that stays the same when tabs are added or moved, such as |
ChildContentDisabledHeaderHeaderTemplateTabPanel.Header.LazyMountTabs.LazyMount. Mount a panel of a form's editors with the tabs (false), so the form validates and saves the fields on it before it is opened.Value*Tabs.SelectedTab holds and the URL carries. A short name that stays the same when tabs are added or moved, such as