Skip to content
IzzyBlazor

Enter all results ↑ ↓ move Esc close

TabNav

Since 0.1.0-alpha.22
Links to pages of their own, drawn as tabs.

Tabs that are links to pages of their own, for sections split across routes (/settings/profile, /settings/billing): a nav of real links drawn as tabs, with no panels and no script needed. The server marks the tab for the current URL.

Each TabLink is a link to its page, here to this page with ?view=. The server marks the tab for the current URL as current.

Static

Preview

The profile page: your name, photo and email.

Code

Usage.razor
@inject NavigationManager Navigation

@* Each TabLink is a link, here to this page with ?view= (in an app, usually its own route), and
   the one for the current address is marked on the server. Profile's link has no view: it's
   current until a link with one matches. *@
<Stack Gap="2" Grow>
    <TabNav Label="Settings">
        <TabLink Href="@To(null)" Label="Profile" Icon="Lucide.User" />
        <TabLink Href="@To("billing")" Label="Billing" Icon="Lucide.CreditCard" />
        <TabLink Href="@To("audit")" Label="Audit" Disabled DisabledReason="On the Business plan" />
        <TabLink Href="@To("team")" Label="Team" Icon="Lucide.UsersRound" Badge="4" />
    </TabNav>
    <TextBlock Color="Color.Muted">
        @(View switch
        {
            "billing" => "The billing page: your plan, payment method and invoices.",
            "team" => "The team page: four people have access.",
            _ => "The profile page: your name, photo and email.",
        })
    </TextBlock>
</Stack>

@code {
    [SupplyParameterFromQuery(Name = "view")]
    private string? View { get; set; }

    private string To(string? view) => Navigation.GetUriWithQueryParameter("view", view);
}

Add this example to a page with the izzy CLI:

bash
izzy add component TabNav --at <file>:<line>

Variant, Size and FullWidth work as on Tabs.

A tab stays current on the pages below its link, so a settings tab is current on settings/billing too. To stop that, set Match="NavLinkMatch.All".

A Disabled tab isn't a link. To say why, set DisabledReason, which shows as its tooltip.

Counts that fit a phone

Badge puts a count after a tab's label, and BadgeStatus colors one that needs attention. A row of five tabs with counts is too wide for a phone, so set BadgeVisibleFrom="Breakpoint.Sm" on the counts that matter less: they show from Sm up.

Static

Code

Counts.razor
@inject NavigationManager Navigation

@* A support queue's status tabs, each with its count: on a phone only Urgent keeps its count, so
   all five tabs fit. *@
<TabNav Label="Status" Grow>
    <TabLink Href="@To(null)" Label="All" Badge="128" BadgeVisibleFrom="Breakpoint.Sm" Current="Shown is null" />
    <TabLink Href="@To("open")" Label="Open" Badge="14" BadgeVisibleFrom="Breakpoint.Sm" />
    <TabLink Href="@To("waiting")" Label="Waiting" Badge="6" BadgeVisibleFrom="Breakpoint.Sm" />
    <TabLink Href="@To("urgent")" Label="Urgent" Badge="3" BadgeStatus="Status.Danger" />
    <TabLink Href="@To("closed")" Label="Closed" Badge="105" BadgeVisibleFrom="Breakpoint.Sm" />
</TabNav>

@code {
    [SupplyParameterFromQuery(Name = "status")]
    private string? Shown { get; set; }

    private string To(string? status) => Navigation.GetUriWithQueryParameter("status", status);
}

Parts

Written inside TabNav. The API page lists their parameters.

  • TabLink: a tab in a TabNav: a link to its own page, marked current from the URL on the server.

Mode support

What works in each mode, TabNav
FeatureStaticInteractive
The current page's tab marked on the serverYesYes
Links told apart by the query, one current at a timeYesYes
A tab marked current from C# (TabLink Current)YesYes

Static: static server-side rendering, with no circuit and no WebAssembly. Interactive: Server, WebAssembly or Auto.

Without JavaScript

Every page starts as plain HTML: before IzzyBlazor's script loads on a static page, while an interactive page prerenders, and with JavaScript off. With JavaScript off, links that don't fit scroll by touch, trackpad or Shift+wheel only, and the current one isn't scrolled into view.

Accessibility

  • It's a nav of plain links that Tab moves between (no arrow keys, as these aren't ARIA tabs).
  • The current page's link has aria-current; a disabled one is a link with no href, announced as disabled (aria-disabled), and its DisabledReason is its tooltip and description.
  • Label names the nav. Give each its own when a page has more than one, or when the purpose isn't clear from the heading before it.

Parameters

TabNav parameters
PropTypeDefault
LabelThe tab strip's name for screen readers, such as "Account settings".string?
VariantHow the tabs look.TabsVariantTabsVariant.Line
SizeTab height and text size, shared with buttons and fields.ControlSizeControlSize.Md
FullWidthStretches the tabs to share the full width (or, vertical, the list's width).boolfalse
IdThe element id.string?
ChildContentThe tabs.RenderFragment?

See also

  • Tabs: switches between panels, even with JavaScript off.
  • NavMenu: lists links and marks the current page.
  • SegmentedControl: lets the user pick one of a few choices from joined buttons.
  • Blocks that use it: Pricing.

Connection lost

Rejoining the server…