Tabs switch between panels of one screen: Overview, Activity, Settings. The selected tab is marked by an indicator that moves with a native spring, and every panel stays mounted so its scroll position and inputs survive switching.
Use SegmentedControl for a compact mode switch inside a form, and a tab bar (navigation) to move between screens.
Anatomy
import { Tabs } from "nitro-ui-sdk/tabs";
const item = { key: "overview", label: "Overview" };
<Tabs.Root items={[item]}>
<Tabs.List>
<Tabs.Tab tab={item}>
<Tabs.Label>Overview</Tabs.Label>
</Tabs.Tab>
</Tabs.List>
<Tabs.Panel tab="overview" />
</Tabs.Root>;
| Part |
Description |
Root |
Owns the selection. Renders a default List when it has no children. |
List |
The tab strip: a track (pill), a glass capsule (glass) or a baseline (underline), with the moving indicator. Renders one Tab per item by default. Scrolls sideways when scrollable. |
Tab |
One tab, a VoiceOver tab with the selected trait. Renders its Label by default. |
Label |
The tab text, semibold while selected. |
Panel |
The content of one tab. Inactive panels collapse and leave the accessibility tree and the agent snapshot. |
Usage
import { Text } from "nitro-ui-sdk/text";
import { Tabs } from "nitro-ui-sdk/tabs";
const items = [
{ key: "overview", label: "Overview" },
{ key: "activity", label: "Activity" },
];
<Tabs.Root items={items} defaultValue="overview">
<Tabs.List />
<Tabs.Panel tab="overview">
<Text>Unread threads</Text>
</Tabs.Panel>
<Tabs.Panel tab="activity">
<Text>Delivery events</Text>
</Tabs.Panel>
</Tabs.Root>;
Variants and sizes
| Variant |
Look |
pill |
A default track with a surface thumb (with shadow.surface in light mode). The default. |
underline |
Text tabs over a hairline baseline, with a 2 pt accent line under the selected tab. |
glass |
A segmented pill on Liquid Glass with an accentSoft thumb, for tabs floating over media. |
Sizes sm | md | lg (default md): heights 44, 44, 52 pt; label steps footnote, subheadline, body. Every tab keeps a 44 pt target. scrollable keeps each tab at its natural width and lets the strip scroll; otherwise tabs share the width equally.
import { Tabs } from "nitro-ui-sdk/tabs";
const items = [{ key: "overview", label: "Overview" }, { key: "activity", label: "Activity" }];
<Tabs.Root items={items} variant="underline" size="lg" scrollable />;
States
- Selected: the indicator moves to the tab and its label turns semibold (
foreground, or accentSoftForeground on glass).
- Disabled: a disabled item (
disabled: true) or the whole group (disabled on Root) uses opacity.disabled and refuses selection.
- Pressed: the native
Semantics highlight dims the tab while the touch is down.
Controlled
value/defaultValue/onValueChange over item keys. details.preventDefault() declines a change. A controlled change reports requested to the controller until the owner re-renders.
When items change and the uncontrolled selection becomes unavailable, Tabs falls back to the first enabled tab without calling onValueChange. A controlled owner continues to supply the key. The indicator clears while that key has no mounted tab.
import { useState } from "react";
import { Tabs } from "nitro-ui-sdk/tabs";
const items = [{ key: "overview", label: "Overview" }, { key: "activity", label: "Activity" }];
function Sections() {
const [tab, setTab] = useState("overview");
return <Tabs.Root items={items} value={tab} onValueChange={(next) => setTab(next)} />;
}
Liquid Glass
variant="glass" draws the strip on MaterialView. Glass is drawn only when theme.material === "glass" (requested, iOS 26 or later, transparency not reduced); otherwise the strip shows the opaque overlay fill with a border. The accentSoft thumb and its accentSoftForeground label stay legible on both.
Props
Tabs.Root
| Prop |
Type |
Default |
Description |
items |
readonly TabItem[] |
|
Required. { key: string; label: string; disabled?: boolean }. |
value |
string |
|
Controlled selected key. |
defaultValue |
string |
first enabled key |
Initial key when uncontrolled. |
onValueChange |
(value: string, details: ActionDetails) => void |
|
Called before a change; preventDefault() declines. |
disabled |
boolean |
false |
Disables every tab. |
variant |
"underline" | "pill" | "glass" |
"pill" |
Look. |
size |
"sm" | "md" | "lg" |
"md" |
Height and label size. |
scrollable |
boolean |
false |
Natural-width tabs in a horizontal scroll view. |
label |
string |
selected tab’s label |
The tab list’s agent name. |
api |
Controller<TabsActions> |
|
From tabsPrimitive.createApi(). |
agentId |
string |
|
Agent identity of the group. |
styles |
TabsStyles |
|
Per-part style resolvers. |
layout |
LayoutStyleProps |
|
Layout of the root. |
Tabs.List
| Prop |
Type |
Default |
Description |
children |
ReactNode |
one Tab per item |
Custom tabs. |
part |
TabsPart |
"list" |
Resolve another part’s style. |
Tabs.Tab
| Prop |
Type |
Default |
Description |
tab |
TabItem |
|
Required. The item this tab selects. |
children |
ReactNode |
<Tabs.Label> |
Custom content, e.g. an icon or a badge. |
part |
TabsPart |
"tab" |
Resolve another part’s style. |
Tabs.Label
| Prop |
Type |
Default |
Description |
children |
string |
|
The text. |
part |
TabsPart |
"label" |
Resolve another part’s style. |
Tabs.Panel
| Prop |
Type |
Default |
Description |
tab |
string |
|
Required. The key of its tab. |
children |
ReactNode |
|
Panel content. |
part |
TabsPart |
"panel" |
Resolve another part’s style. |
Controller API
import { Tabs, tabsPrimitive } from "nitro-ui-sdk/tabs";
const items = [{ key: "overview", label: "Overview" }, { key: "activity", label: "Activity" }];
const api = tabsPrimitive.createApi();
<Tabs.Root items={items} api={api} />;
api.current?.select("activity");
| Action |
Signature |
Result |
select |
select(key: string, source?: ActionSource): ChangeStatus |
accepted, requested (controlled), refused, disabled or unavailable (unknown or disabled key). |
next |
next(source?: ActionSource): ChangeStatus |
Selects the next enabled tab. Starts at the first enabled tab when a controlled key is unavailable. Returns unavailable at the end. |
previous |
previous(source?: ActionSource): ChangeStatus |
Selects the previous enabled tab; unavailable at the start. |
Styles
import { Tabs, type TabsStyles } from "nitro-ui-sdk/tabs";
const items = [{ key: "overview", label: "Overview" }, { key: "activity", label: "Activity" }];
const styles: TabsStyles = {
label: ({ tokens, state }) => ({ text: { color: state.selected ? tokens.colors.accent : tokens.colors.muted } }),
indicator: ({ tokens }) => ({ style: { background: tokens.colors.accentSoft } }),
};
<Tabs.Root items={items} styles={styles} />;
Parts: root, list, tab, label, indicator, panel. Resolvers receive { tokens, variant, size, state } with state: { disabled: boolean; value: string; selected: boolean } (selected is per tab for tab and label). Custom children opt in with useTabsPart(props, "label").
Accessibility
- Each tab is a VoiceOver tab with its label, the selected trait and the disabled trait.
- Only the active panel is in the accessibility tree; the others are hidden while mounted.
- A selection change by touch plays the selection haptic; agent and API changes do not.
Agent API
| Action |
Arguments |
Notes |
select |
key: string |
On the group (component Tabs, role group, value = selected key, options = items). Waits for a controlled owner’s render and reports the outcome. |
next / previous |
none |
On the group. |
select |
none |
On each tab (component Tabs, role tab, named by its label). |
Controls in inactive panels are not discoverable.
|
iOS |
Android |
| Tabs |
Composed Semantics tabs; the indicator measures the selected tab after layout and moves with a native spring (animateSpring, no JavaScript per frame), without animation under Reduce Motion. Verified in the iOS harness. |
Same composition; written, compile-only on this machine. |
| Glass |
Liquid Glass on iOS 26+, opaque fallback otherwise. |
Opaque fallback. |