Skip to content
Razor catalogue

On this page

@addTagHelper *, Webority.Ui.Razor

The tab strip

Tabs switch between a few peer views of one page, with one view active at a time.

A controlled tab strip
Show code
<app-tabs aria-label="Project filters">
    <app-tab title="All"></app-tab>
    <app-tab title="Active"></app-tab>
    <app-tab title="Archived"></app-tab>
</app-tabs>

Emphasis and state

A tab can carry an icon, a count, a tone or a disabled state, beyond its plain name.

Icons, counts and states
Show code
<app-tabs aria-label="Project filters">
    <app-tab title="Overview" icon="folder-open" count="12" tone="AppTabTone.Success"></app-tab>
    <app-tab title="Activity" icon="bell" count="3" tone="AppTabTone.Warning"></app-tab>
    <app-tab title="Delete" danger="true"></app-tab>
    <app-tab title="Archived" disabled="true"></app-tab>
</app-tabs>

Variant, size and fit

Pills change the chrome of the strip, not its behaviour, and size and fitted layout tune it to the space.

Pills
Show code
<app-tabs variant="Pills" aria-label="Sections">
    <app-tab title="Overview"></app-tab>
    <app-tab title="Activity"></app-tab>
    <app-tab title="Settings"></app-tab>
</app-tabs>
Sizes
Show code
<app-tabs size="Sm" aria-label="Sections">…</app-tabs>
<app-tabs size="Md" aria-label="Sections">…</app-tabs>
<app-tabs size="Lg" aria-label="Sections">…</app-tabs>
Fitted
Show code
<app-tabs variant="Pills" fitted="true" aria-label="Sections">
    <app-tab title="Overview"></app-tab>
    <app-tab title="Activity"></app-tab>
    <app-tab title="Settings"></app-tab>
</app-tabs>

Vertical orientation

A vertical strip works as a settings rail, with the arrow keys moving up and down between tabs.

A side rail
Overview: the high-level summary of the project.
Activity: the running log of recent changes.
Settings: configuration for this project.
Show code
<app-tabs orientation="Vertical" aria-label="Project sections">
    <app-tab title="Overview">Overview: the high-level summary of the project.</app-tab>
    <app-tab title="Activity">Activity: the running log of recent changes.</app-tab>
    <app-tab title="Settings">Settings: configuration for this project.</app-tab>
</app-tabs>

Overflow

Tabs that do not fit scroll with chevrons, or move into a More menu when the menu option is set.

Too many tabs to fit
Show code
<app-tabs aria-label="Many sections">
    <app-tab title="Overview"></app-tab>
    <app-tab title="Activity"></app-tab>
    <app-tab title="Settings"></app-tab>
    <app-tab title="Members"></app-tab>
    <app-tab title="Integrations"></app-tab>
    <app-tab title="Billing"></app-tab>
    <app-tab title="Security"></app-tab>
    <app-tab title="API"></app-tab>
    <app-tab title="Webhooks"></app-tab>
    <app-tab title="Audit log"></app-tab>
    <app-tab title="Exports"></app-tab>
    <app-tab title="Danger zone"></app-tab>
</app-tabs>
Extras in a More menu
Show code
<app-tabs overflow="Menu" aria-label="Many sections">
    <app-tab title="Overview"></app-tab>
    <app-tab title="Activity"></app-tab>
    <app-tab title="Settings"></app-tab>
    <app-tab title="Members"></app-tab>
    <app-tab title="Integrations"></app-tab>
    <app-tab title="Billing"></app-tab>
    <app-tab title="Security"></app-tab>
    <app-tab title="API"></app-tab>
    <app-tab title="Webhooks"></app-tab>
    <app-tab title="Audit log"></app-tab>
    <app-tab title="Exports"></app-tab>
    <app-tab title="Danger zone"></app-tab>
</app-tabs>

Every option

Every value of every prop, one cell each.

tabs: label and key

title="Overview": the text of the tab
key (React only): identifies the tab, not shown

tabs: icon and image

icon="folder-open"
image="/img/sample-logo.png": wins over icon
image-alt="Overview": the alt text, not shown

tabs: tooltip

tooltip="The high-level summary": a hint on hover and focus

tabs: count, countLabel and tone

count="12"
tone="success": tints the count pill
tone="warning": tints the count pill
tone="danger": tints the count pill
tone="info": tints the count pill
count-label="3 open": shown in place of count

tabs: state

danger="true": draws the tab and its indicator in the danger colour
disabled="true": the tab cannot be selected
active="true" on a disabled tab: falls back to the first enabled tab

tabs: link

href="#every-option": a link tab, not a button
Overview
to (React only): a router route, Razor uses href
target="_blank": opens the link in a new tab
Docs ↗
rel="nofollow": replaces the default rel of a _blank link
Docs ↗

value

active="true" on Activity: the selected tab

onChange

onChange (React only): the callback that receives the picked key

linkComponent

linkComponent (React only): Razor link tabs use href

variant

variant="underline" (default)
variant="pills"

orientation

orientation="horizontal" (default)
orientation="vertical"

size

size="sm"
size="md" (default)
size="lg"

fitted

fitted="false" (default): tabs keep their width
fitted="true": tabs share the width equally

overflow

overflow="scroll" (default): edges fade and chevrons appear
overflow="menu": the tabs that do not fit go in a More menu

maxVisible

max-visible="3": the tabs past three go in a More menu

moreLabel

more-label="All sections": the More button text, with overflow menu

activation

activation="automatic" (default): arrows also select
activation="manual": arrows move focus, Enter or Space selects

ariaLabel

aria-label="Project sections": the accessible name, not shown

className and style

class and style: pass through to the outer div, not shown

tab content

content: the pane shown when the tab is active
Overview: the high-level summary.

Guidance

What to do, and what to avoid.

Use it when

  • A record or page has a few peer sections (Overview, Activity, Settings) the user switches between.
  • A list needs quick filters (All / Active / Archived) that swap the rows in place.
  • The set of views is small and stable, so every one stays a single click away.

Reach for something else when

  • The views are ordered steps that must be completed in sequence. → a wizard or stepper
  • There are many options to choose from. → AppSelect
  • Each view is a full destination with its own URL. → router navigation
  • You are toggling a single on/off setting. → AppSwitch

Short labels for peer views

Do

A few short, peer labels: the user sees every view at a glance.

Avoid

Sentence-long labels break the scannable rhythm a tab strip depends on.

Tabs switch views, never steps

Do

A count on a filter tab tells the user how much is behind it before they click.

Avoid

Fitted pills read as a segmented control. Do not use them for sequential steps; that is a stepper.

Reference

Try every prop, read the full list, and check keyboard and screen reader behaviour.

underline pills
horizontal vertical
sm md lg
automatic manual
scroll menu
Overview.
Activity.
Settings.
Archived.
React, generated from the controls
<AppTabs
  tabs={tabs}
  value="overview"
  onChange={onChange}
  ariaLabel="Playground tabs"
/>
Razor, the same props
<app-tabs aria-label="Playground tabs">
    <app-tab title="Overview">Overview.</app-tab>
    <app-tab title="Activity">Activity.</app-tab>
    <app-tab title="Settings">Settings.</app-tab>
    <app-tab title="Archived">Archived.</app-tab>
</app-tabs>

24 props. The 3 most used come first.

Used on most screens 3 props

PropTypeDefaultDescription
variantdefault underline Underline | Pills underline The look of the strip: an underline with a sliding bar, or pills.
orientationdefault horizontal Horizontal | Vertical horizontal horizontal lays the tabs in a row. vertical renders a side rail.
sizedefault md Sm | Md | Lg md The size of the tabs.

Less common 21 props

PropTypeDefaultDescription
fitteddefault false bool false The tabs share the width equally instead of scrolling.
overflowdefault scroll Scroll | Menu scroll What a horizontal strip does when the tabs do not fit. scroll scrolls it with chevrons and edge fades. menu moves the tabs that do not fit into a More menu and always keeps the selected tab visible. Ignored when orientation is vertical.
max-visibledefault - int - Puts the tabs that do not fit the row in a More menu, as overflow menu does. The selected tab always stays visible.
more-labeldefault More string More The text of the More button when overflow is menu.
activationdefault automatic Automatic | Manual automatic Whether the arrow keys also select. automatic selects as focus moves. manual moves focus only and selects on Enter or Space.
(app-tab) titledefault - string - The label of a tab. Each app-tab child is one tab.
(app-tab) disableddefault false bool false Renders the tab as unavailable: it can't be selected.
(app-tab) icondefault - string - Library icon name shown before the label.
(app-tab) imagedefault - string - A picture URL shown before the label, such as a logo or avatar. Wins over icon.
(app-tab) image-altdefault - string - The alt text of the image.
(app-tab) tooltipdefault - string - A hover/focus hint on the tab, drawn as a CSS-only bubble rather than a native tooltip, which cannot attach to a tab button that already runs its own tab script.
(app-tab) countdefault - int? - A count badge shown after the label.
(app-tab) tonedefault - success | warning | danger | info - Tone tint for the count badge.
(app-tab) dangerdefault false bool false Destructive styling for the tab.
(app-tab) hrefdefault - string - Turns the tab into a real link (an anchor with href) instead of a panel-switching button: the browser gives right-click “Open in new tab”, Ctrl/⌘-click and middle-click for free. A link tab navigates and owns no pane.
(app-tab) targetdefault - string - Anchor target for a link tab; _blank opens it on the next screen on a plain click.
(app-tab) reldefault - string - Anchor rel for a link tab; defaults to noopener noreferrer when target="_blank".
(app-tab) activedefault false bool false Marks this tab as current: use with link tabs to flag the one matching the route. Panel tabs may omit it (first enabled is active). React derives this from value.
(app-tab content)default - markup - The pane shown when the tab is active (inner content).
style / class / other attrsdefault - string - Unbound attributes on app-tabs pass through to the rendered outer div.app-tabs-group (lands on the wrapper, not the role="tablist" element).
aria-labeldefault - string - The accessible name of the tab strip.

Screen reader

5 notes
  • The strip is a tablist and each tab has role tab with aria-selected; a vertical strip sets aria-orientation, and ariaLabel names the strip.
  • Only one tab is in the tab order at a time (a roving tabindex). Arrow keys, Home and End move between tabs and skip disabled ones; Up and Down replace Left and Right when vertical.
  • Automatic activation selects a tab as focus moves; manual activation moves focus only and selects on Enter or Space.
  • A tab with href or to is a real link, so open in new tab and middle click work; a link tab is not selected by arrow keys, and a new-window link gets rel noopener noreferrer.
  • The scroll chevrons are left out of the tab order and carry accessible names, and the sliding indicator is hidden from assistive technology.

Do and avoid

2 pairs

Short labels for peer views

Do

A few short, peer labels: the user sees every view at a glance.

Avoid

Sentence-long labels break the scannable rhythm a tab strip depends on.

Tabs switch views, never steps

Do

A count on a filter tab tells the user how much is behind it before they click.

Avoid

Fitted pills read as a segmented control. Do not use them for sequential steps; that is a stepper.