Tabs
Switches between related panels of content in the same view.
Selector: mui-tabs
import { Tabs, TabList, Tab, TabPanel } from '@mushilu-san/ui/navigation';Loading example…
Overview
mui-tabs holds the active value, mui-tab-list holds the mui-tab triggers, and each mui-tab-panel shows when its value matches.
activeTab model, so you can bind it with [(activeTab)] to sync it with the URL or other state.
When to use
Grouping related content that users switch between without leaving the page. Settings or detail screens with a few peer sections.
When not to use
Triggering an action. Tabs only switch views. Use Button instead.Sequential steps that must be done in order. Use a stepper or a multi-step form. More than about six sections. Use a sidebar or a menu.
Examples
Vertical
orientation="vertical", Up and Down arrows move between tabs.
Loading example…
Disabled tab
Loading example…
Guidelines
Do
Give every mui-tab-listanaria-labelthat names the group.Keep tab labels short, one or two words. Use values that are unique on the page. Tab ids are derived from them.
Don't
Do not nest tabs inside tabs. Do not put the only path to critical content behind a disabled tab without explaining why.
Accessibility
Roles and attributes
| Element | Role | Notes |
|---|---|---|
mui-tab-list | tablist | aria-orientation follows the orientation input. |
mui-tab | tab | aria-selected, aria-controls; aria-disabled when disabled. |
mui-tab-panel | tabpanel | aria-labelledby points at its tab. |
Keyboard
| Keys | Action |
|---|---|
| ArrowLeftArrowRight | |
| ArrowUpArrowDown | |
| HomeEnd | |
| EnterSpace |
Activation is manual. Arrow keys move focus, and Enter or Space selects. This avoids loading panels the user is only passing over. Only the active tab is in the tab order (roving tabindex). Always set an initialactiveTab; with the default empty value no tab is focusable.Inactive panels are hiddenand their content is not rendered. The active panel is itself focusable (tabindex="0").
API
Tabs
| Name | Type | Default | Description |
|---|---|---|---|
orientation | 'horizontal' | 'vertical' | 'horizontal' | Whether the tab list runs horizontally or vertically. Default `horizontal`. |
| Name | Type | Default | Description |
|---|---|---|---|
activeTab | string | '' | Value of the selected tab. Two-way bindable with `[(activeTab)]`. |
CSS parts
::part(tabs)
TabList
CSS parts
::part(tab-list)
Tab
| Name | Type | Default | Description |
|---|---|---|---|
value | string | — | Value that identifies this tab and its panel. |
disabled | boolean | false | Disables this tab. It is skipped by the arrow keys. Accepts attribute presence, e.g. <… disabled>. |
CSS parts
::part(tab)
TabPanel
| Name | Type | Default | Description |
|---|---|---|---|
value | string | — | Value of the tab that controls this panel. |
CSS parts
::part(tab-panel)
Tokens
--mui-color-primary--mui-color-border--mui-color-text--mui-color-text-muted--mui-color-text-disabled--mui-color-focus-ring--mui-touch-target