Web · Components
Tabs
Tabs switching between several views in the same area.
5 exports
Live example
Preview
General settings go here.
Notifications settings go here.
Security settings go here.
Code
Events
- Events appear here when you interact with the preview.
Import
Tabs switching between several views in the same area. Tabs are given with the items array; buttons and panels are rendered automatically.
- Keyboard: arrow keys move between tabs and select them, Home/End go to the first and last tab. The tab list is a single Tab stop.
- Mobile: If the tabs don't fit, the list scrolls horizontally (hidden scrollbar, snapping) and the selected tab is brought into view automatically.
- Unselected panels aren't removed from the DOM but hidden with
hidden; so form state inside them is kept and find in page works. - If you only need the tab buttons (e.g. the content is elsewhere), omit
contentand useonValueChange.
Examples
TabItem
interfaceA tab inside Tabs.
| Name | Type | Description |
|---|---|---|
value | string | Unique value of the tab. |
label | ReactNode | Text shown on the tab button. |
icon? | IconProp | Icon before the label: name or element. |
badge? | ReactNode | Small content after the label (e.g. a count badge). |
content? | ReactNode | Content shown while the tab is selected. |
disabled? | boolean | Can't be selected. |
tooltip? | TooltipProp | Tooltip shown when hovering the tab or focusing it with the keyboard (e.g. for icon-only tabs or the reason a tab is disabled). See TooltipProp. |
TabsVariant
typeLook of the tabs.
pill: the selected tab looks like a white card on a gray background.line: a line under the selected tab.
TabsClassNames
interfaceClasses that can be passed to the inner parts of Tabs.
| Name | Type | Description |
|---|---|---|
list? | string | List of tab buttons. |
tab? | string | Each tab button. |
panel? | string | Each content panel. |
TabsProps
interfaceProps of the Tabs component.
Extends: Omit<ComponentProps<"div">, "defaultValue" | "onChange" | "children">
| Name | Type | Default | Description |
|---|---|---|---|
items | readonly TabItem[] | Tabs. | |
value? | string | Value of the selected tab in controlled use. | |
defaultValue? | string | Initially selected tab in uncontrolled use. If omitted, the first selectable tab is selected. | |
onValueChange? | (value: string) => void | Called when the selected tab changes. | |
orientation? | "horizontal" | "vertical" | "horizontal" | Layout of the tabs and direction of the arrow keys. |
variant? | TabsVariant | CustomVariant<"tabs"> | "pill" | Look: built-in (TabsVariant) or a custom look added with defineAppearance (its classes are added to the tab list; use [&_[role=tab]]:… for tabs). If omitted, UIProvider appearance.defaults.tabs.variant. |
effect? | EffectProp | Effect of each tab button (e.g. "ripple", "shine"). If omitted, UIProvider appearance.defaults.tabs.effect. See BuiltinEffect. | |
fullWidth? | boolean | Tabs share the full width of the list equally. | |
label? | string | Screen reader name of the tab list. | |
classNames? | TabsClassNames | Classes added to the inner parts. |