Tab component

The <Tab> component is used for hiding content behind a selectable item. This can also be used as a pseudo-navigation for a page, where the tabs are links and the tab-items are the content.

There are two pieces to a tabbed interface: the tabs themselves, and the content for each tab.

  • <Tabs> container for Tab items
    • <Items> container for tab items
      • <Tab> clickable tab item
    • <Content> container for tab panels
      • <TabPanel> container for tab content

The tabs are container for tab items. Each tab item contains a link to a tab panel. The Name of each tab item should match the Name of a tab panel.

  • <TabsContent> container for tab panels
    • <TabPanel> container for tab content

The tab content container is used to hold tab panels. Each content pane also has a unique Name, which is targeted by a link in the tab-strip.

Most of the time you will only need to use Tabs component as it is crafted to hold both clickable tab items and tab content. Only in the advanced scenario where the content will be separated from the tab items you will need to use <TabsContent> component.

Examples

Basic

Content for home.
Content for profile.
Content for messages.
Content for settings.
<Tabs SelectedTab="@selectedTab" SelectedTabChanged="@OnSelectedTabChanged">
    <Items>
        <Tab Name="home">Home</Tab>
        <Tab Name="profile">Profile</Tab>
        <Tab Name="messages">Messages</Tab>
        <Tab Name="settings">Settings</Tab>
    </Items>
    <Content>
        <TabPanel Name="home">
            Content for home.
        </TabPanel>
        <TabPanel Name="profile">
            Content for profile.
        </TabPanel>
        <TabPanel Name="messages">
            Content for messages.
        </TabPanel>
        <TabPanel Name="settings">
            Content for settings.
        </TabPanel>
    </Content>
</Tabs>
@code{
    string selectedTab = "profile";

    private Task OnSelectedTabChanged( string name )
    {
        selectedTab = name;

        return Task.CompletedTask;
    }
}

Lazy Load

You are able to set the Tabs component to lazy load your tabs.
This Tabs component is set to LazyLoad mode, meaning each tab will only be rendered/loaded the first time it is visited. This is specially useful when you want to delay some heavy or long waited operations for when the tab is actually clicked instead.
<Tabs Mode="TabsMode.LazyLoad" SelectedTab="tab1">
    <Items>
        <Tab Name="tab1">Tab 1</Tab>
        <Tab Name="tab2">Tab 2</Tab>
    </Items>
    <Content>
        <TabPanel Name="tab1">
            This Tabs component is set to <code>LazyLoad</code> mode, meaning each tab will only be rendered/loaded the first time it is visited.
            This is specially useful when you want to delay some heavy or long waited operations for when the tab is actually clicked instead.
            <TextEdit></TextEdit>
        </TabPanel>
        <TabPanel Name="tab2">
            <TextEdit></TextEdit>
        </TabPanel>
    </Content>
</Tabs>

Lazy Reload

You are able to set the Tabs component to lazy load your tabs everytime.
This Tabs component is set to LazyReload mode, meaning that only the active tab will have it's html rendered at a time. Try typing some text in the provided Text components and changing between tabs, the tab will always be refresh as the tab content is always lazy loaded, therefore re-calculated.
<Tabs Mode="TabsMode.LazyReload" SelectedTab="tab1">
    <Items>
        <Tab Name="tab1">Tab 1</Tab>
        <Tab Name="tab2">Tab 2</Tab>
    </Items>
    <Content>
        <TabPanel Name="tab1">
            This Tabs component is set to <code>LazyReload</code> mode, meaning that only the active tab will have it's html rendered at a time. 
            Try typing some text in the provided Text components and changing between tabs, the tab will always be refresh as the tab content is always lazy loaded, 
            therefore re-calculated.
            <TextEdit></TextEdit>
        </TabPanel>
        <TabPanel Name="tab2">
            <TextEdit></TextEdit>
        </TabPanel>
    </Content>
</Tabs>

Functions

Name Description
SelectTab(string name) Sets the active tab by the name.

Attributes

Tabs

Name Description Type Default
Pills Makes the tab items to appear as pills. bool false
FullWidth Makes the tab items to extend the full available width. bool false
Justified Makes the tab items to extend the full available width, but every item will be the same width. bool false
TabPosition Defines the placement of a tab items. TabPosition Top
SelectedTab Currently selected tab name. string null
SelectedTabChanged Occurs after the selected tab has changed. EventCallback<string>
VerticalItemsColumnSize Controls the size of the items bar when in vertical mode. If left undefined it will default to the ColumnSize.IsAuto. IFluentColumn
Mode Gets or sets the TabsMode. TabsMode TabsMode.Default

Tab

Name Description Type Default
Name Defines the unique tab name. string null
Clicked Occurs when the button is clicked. EventCallback
Disabled Prevents user interactions and make it appear lighter. bool false

TabsContent

Name Description Type Default
SelectedPanel Currently selected panel name. string null
SelectedPanelChanged Occurs after the selected panel has changed. EventCallback<string>

TabPanel

Name Description Type Default
Name Defines the panel name that must match the corresponding tab name. string null