Layout
TwTabs
TwTabs is a Blazor tabs component, built from TwTabContainer and TwTab. Set Label, Icon, Color, Dense and Disabled, and scroll tabs that do not fit.
Last updated
Basic tabs
Use
TwTabContainer and TwTab to split content into switchable panels. By default the tab bar floats on its own as a segmented control, separate from the content below it.This is the content of Tab 1.
RAZOR
<TwTabContainer AriaLabel="Example tabs 1">
<TwTab Label="Tab 1">
<p>This is the content of Tab 1.</p>
</TwTab>
<TwTab Label="Tab 2">
<p>This is the content of Tab 2.</p>
</TwTab>
</TwTabContainer>Container tab colors
Set
TabColor on TwTabContainer to choose the colour of the selected tab's label. Unselected tabs stay neutral, so the selected tab is always the one that stands out.Setting the TabColor property on the TwTabContainer sets the selected colour for every tab within that container.
RAZOR
<TwTabContainer AriaLabel="Example tabs 2" TabColor="Color.Accent">
<TwTab Label="Tab 1">
<p>Setting the <code>TabColor</code> property on the <code>TwTabContainer</code> sets the selected colour for every tab within that container.</p>
</TwTab>
<TwTab Label="Tab 2">
<p>This is the content of Tab 2.</p>
</TwTab>
<TwTab Label="Tab 3">
<p>This is the content of Tab 2.</p>
</TwTab>
</TwTabContainer>Single tab colors
Set
Color on an individual TwTab to give just that tab its own selected colour. Select each tab below to see it.Setting the Color property on an individual tab sets the colour it uses while it is selected.
RAZOR
<TwTabContainer AriaLabel="Example tabs 3">
<TwTab Label="Tab 1" Color="Color.Danger">
<p>Setting the <code>Color</code> property on an individual tab sets the colour it uses while it is selected.</p>
</TwTab>
<TwTab Label="Tab 2" Color="Color.Success">
<p>This is the content of Tab 2.</p>
</TwTab>
<TwTab Label="Tab 3" Color="Color.Primary">
<p>This is the content of Tab 3.</p>
</TwTab>
</TwTabContainer>Tabs with cards
The tab panel has no border or background of its own, so content that brings its own surfaces, such as cards, sits directly on the page below the tab bar.
Revenue
Revenue is up 12% on last month.
Customers
48 new customers signed up this week.
Container tabs
Set
Container on TwTabContainer to draw underlined tabs joined to a bordered panel. This suits plain text or form fields that have no surface of their own. Add TransparentContainer to drop the container's background and keep only its border. Keyboard navigation works the same in both layouts.Update your name, photo and contact details.
RAZOR
<TwTabContainer AriaLabel="Example tabs 7" Container>
<TwTab Label="Profile">
<p>Update your name, photo and contact details.</p>
</TwTab>
<TwTab Label="Security">
<p>Change your password and manage two step verification.</p>
</TwTab>
<TwTab Label="Billing">
<p>View invoices and update your payment method.</p>
</TwTab>
</TwTabContainer>Dense tabs
Set
Dense on TwTabContainer to render more compact tabs.This is the content of Tab 1.
RAZOR
<TwTabContainer AriaLabel="Example tabs 4" Dense>
<TwTab Label="Tab 1">
<p>This is the content of Tab 1.</p>
</TwTab>
<TwTab Label="Tab 2">
<p>This is the content of Tab 2.</p>
</TwTab>
</TwTabContainer>Disabled tabs
Set
Disabled on a TwTab to prevent it from being selected.This is the content of Tab 1.
RAZOR
<TwTabContainer AriaLabel="Example tabs 5" Dense>
<TwTab Label="Tab 1">
<p>This is the content of Tab 1.</p>
</TwTab>
<TwTab Label="Disabled" Disabled>
<p>This is the content of Tab 2.</p>
</TwTab>
</TwTabContainer>Scrollable tabs with icons
Set
Scrollable to keep the tabs on one line. When they do not fit, arrow buttons appear at the ends to scroll them, and the arrow keys bring the focused tab into view. Give a TwTab an Icon to show it before the label, and use TabBarContent for controls that sit beside the tabs.Overview content.
RAZOR
<div class="max-w-md">
<TwTabContainer AriaLabel="Example tabs 6" Scrollable Dense>
<TabBarContent>
<TwButton Label="New" StartIcon="Icon.Plus_Lg" Dense />
</TabBarContent>
<ChildContent>
<TwTab Label="Overview" Icon="Icon.Speedometer2"><p>Overview content.</p></TwTab>
<TwTab Label="Analytics" Icon="Icon.Bar_Chart_Line"><p>Analytics content.</p></TwTab>
<TwTab Label="Customers" Icon="Icon.People"><p>Customers content.</p></TwTab>
<TwTab Label="Invoices" Icon="Icon.Receipt"><p>Invoices content.</p></TwTab>
<TwTab Label="Settings" Icon="Icon.Gear"><p>Settings content.</p></TwTab>
</ChildContent>
</TwTabContainer>
</div>Theme configuration
Styling is controlled by
TwBlazorTheme.Components (a TwTabTheme), configured via the
AddTwBlazor() options callback described on the Get Started page.
Every property is a set of Tailwind classes, so changes are picked up by your own Tailwind build.
| Property | Type | Controls |
|---|---|---|
TabBase |
string | |
TabPadding |
string | |
TabDensePadding |
string | |
ActiveIndicator |
string | |
InactiveIndicator |
string | |
DisabledTab |
string | |
TabListContainer |
string | |
PanelContainer |
string | |
Background |
string | |
IsolatedTabListContainer |
string | |
IsolatedTab |
string | |
IsolatedTabPadding |
string | |
IsolatedTabDensePadding |
string | |
IsolatedActiveTab |
string | |
IsolatedInactiveTab |
string | |
IsolatedPanelContainer |
string | |
TabBar |
string | |
TabBarContent |
string | |
ScrollContainer |
string | |
ScrollableTabList |
string | |
ScrollButton |
string | |
ScrollButtonStart |
string | |
ScrollButtonEnd |
string |
Full reference: TwTabTheme on the API docs.