UI

Tabs

Switch between related content panels in the same context.

import { Tabs } from '@uthereal/ui/tabs'

Tabs playground

Summary and stats

Loading interactive preview…

Overview

Tabs displays a row or column of tabs that switch between related panels in the same location. Zag manages roving focus, arrow navigation, Home and End, and automatic or manual activation. Pressing a tab selects it on pointer down, the selection indicator glides between tabs for both pointer and keyboard interaction, and incoming panels slide from the direction of travel.

Use Tabs for sibling views of one entity, such as project overview, activity, and files. Use Radio or MorphSelect to select a form value. Use Breadcrumb or links to navigate between routes.

OptionValuesBehavior
variantsoft (default)Raises the selected tab as a shadowed surface pill inside a bordered muted track.
variantunderlineDraws a 2 px accent bar under the selected tab along a hairline rule.
orientationhorizontal (default)Places tabs in a scrollable row above the panel with edge fades and scroll buttons.
orientationverticalPlaces tabs in a column beside the panel. Up and Down arrows navigate; underline faces in.

Usage

'use client'
import { TabPanel, Tabs } from '@uthereal/ui/tabs'

export function ProjectTabs() {
  return (
    <Tabs
      label="Project sections"
      items={[
        { value: 'overview', label: 'Overview' },
        { value: 'activity', label: 'Activity', badge: '3' },
        { value: 'files', label: 'Files' },
      ]}
    >
      <TabPanel value="overview">
        <ProjectSummary />
      </TabPanel>
      <TabPanel value="activity">
        <ActivityFeed />
      </TabPanel>
      <TabPanel value="files">
        <FileList />
      </TabPanel>
    </Tabs>
  )
}

Each TabPanel displays content when its value matches the selected tab. label provides the accessible name of the tab list and is not rendered visually. Pass value and onValueChange to control selection from your application, or omit value to let Tabs manage state from defaultValue.

Examples

Use <SchemaPlayground /> above to test size, fullWidth, activationMode, recipe, theme, and dir. The examples below show distinct layouts and tab content.

Underline variant

Use variant="underline" for a hairline indicator instead of the default soft pill track shown in the playground above.

Summary and stats

Icons, badges, and disabled tabs

Add a leading icon and a trailing badge to any tab. Numeric badges roll changed digits in the direction of the count change while assistive technology reads plain text. Disabled tabs cannot be selected and arrow keys skip them.

Ask a question about this case.

Vertical

Set orientation="vertical" for settings views or long tab lists. Arrow navigation switches to Up and Down, and the underline aligns with the panel edge.

Workspace name, language and time zone.

Panels, overflow, and activation

Supply panels with TabPanel children or renderPanel(item). renderPanel takes precedence over children. Panels stay mounted while hidden so internal state, such as form inputs, persists across tab switches.

Omit both children and renderPanel to render a standalone tab bar that reports selection changes without aria-controls references:

<Tabs label="Views" items={views} value={view} onValueChange={setView} />

When a horizontal tab row overflows its container, the clipped edges fade over 35 px and 33 px scroll buttons appear using scrollPreviousLabel and scrollNextLabel. Each scroll button hides at its scroll limit. Focusing or selecting a tab scrolls it into view clear of both scroll buttons.

Mode / PropBehavior
Uncontrolled (default)Starts at defaultValue or the first enabled tab. Falls back to the initial tab if removed/disabled.
Controlled (value)Host owns selection. onValueChange fires in both modes. Keep one mode for the component lifetime.
activationMode="automatic"Arrow keys move focus and select immediately.
activationMode="manual"Arrow keys move focus only; Enter or Space activates. Use when mounting a panel is expensive.

API reference

Serializable arguments and defaults come directly from tabsConfigSchema.

ArgumentType / defaultDescription
labelRequiredstring—Accessible name of the tab list, e.g. "Project sections". Not shown.
itemsRequiredTabItem[]—The tabs, in order: a unique value, a label, and an optional icon, badge and disabled flag.
defaultValuestring—Tab selected on first render; the first enabled tab when omitted. Later edits do not reset an existing instance.
variantunderline | softDefault: "soft"soft (default, Arc) raises the selected tab as a shadowed pill in a bordered muted track; underline draws an accent line under the selected tab.
sizesm | md | lgDefault: "md"Tab height and text size: 36, 44, or 50 pixels, matching a button of the same size.
orientationhorizontal | verticalDefault: "horizontal"horizontal puts the tabs in a row above the panel; vertical puts them in a column beside it.
activationModeautomatic | manualDefault: "automatic"automatic selects a tab as soon as arrow keys focus it; manual moves focus only, and Enter or Space selects.
fullWidthbooleanDefault: falseHorizontal tabs stretch to share the full width. Ignored when vertical.
scrollPreviousLabelstringDefault: "Scroll tabs back"Name of the button that scrolls an overflowing row back; shown only while the row overflows.
scrollNextLabelstringDefault: "Scroll tabs forward"Name of the button that scrolls an overflowing row forward; shown only while the row overflows.
recipestudio | softDefault: "studio"Visual treatment. Both recipes use the same interaction behavior.
themeTabsTheme—Color mode, accent, and semantic tokens. See Theming for all keys and defaults.
motionnone | subtle | expressiveDefault: "subtle"Indicator animation preset. System reduced-motion preferences take precedence.
motionOptionsTabsMotionOptions—The indicator transition between tabs: a tween with a duration (ms) or a spring.
dirltr | rtl—Reading direction; arrow keys follow it. Omit it to inherit the page direction.

Tab item fields (TabItem)

FieldTypePurpose
valuestringUnique stable key linking the tab to its matching TabPanel.
labelstringVisible tab text.
iconIconNameOptional decorative icon before the label.
badgestringShort count or status (up to 20 characters) after the label.
disabledbooleanDisables pointer and keyboard selection. Default false.

React integration

PropPurpose
value, onValueChangeControl the selected tab value. The callback fires in both modes.
childrenTabPanel elements, one per tab value.
renderPanel(item)Render each tab panel directly; takes precedence over children.
renderIcon(name, context)Replace a tab icon; context provides size, slot ("icon"), and item.
presetApplication defaults overridden by explicit instance props.
tokens--ui-* CSS variables applied after the typed theme on the root element.
ref, className, styleApplied to the root element that carries theme tokens and wraps list + panels.
Native attributesid, aria-*, data-*, and event handlers forwarded to the root element.

TabPanel accepts value, ref, className, and native <div> attributes. Outside Tabs, it renders its children in a plain <div>.

Keyboard & accessibility

KeyInteraction
TabMove focus to the selected tab, then into the active panel.
ArrowLeft, ArrowRightHorizontal: focus previous or next enabled tab, wrapping. Flips in RTL.
ArrowUp, ArrowDownVertical: focus previous or next enabled tab, wrapping.
Home, EndFocus the first or last enabled tab.
Enter, SpaceManual activation: select the focused tab.

The list renders role="tablist" with aria-label={label}, each trigger renders a native <button role="tab"> with aria-selected, and each panel renders role="tabpanel" labelled by its tab. Disabled tabs use native disabled. Exiting panels set inert and pointer-events: none so focus and clicks cannot reach outgoing content.

In RTL (dir="rtl"), logical CSS properties, overflow edge masks, scroll buttons, arrow keys, and horizontal panel slide direction mirror automatically. Under forced-colors: active, focus rings, underline indicators, and soft pill borders use Highlight, and disabled tabs use GrayText.

Motion and theming

The selection indicator glides between tabs on the morph spring (0.42 s, bounce 0.16) scoped per instance with useId(). Override it with motionOptions.indicator. On tab changes, the incoming panel slides 8 px from the direction of travel while fading in over 240 ms, its height springs from the previous panel height on the smooth spring (0.4 s, bounce 0), and the outgoing panel leaves 6 px in the opposite direction over 120 ms.

Setting motion="none" makes indicator moves, panel switches, scroll jumps, badge rolls, and hover color changes immediate (0 ms). System prefers-reduced-motion: reduce disables travel, height springs, and smooth scrolling while keeping an opacity crossfade (100 ms exit, 120 ms enter).

theme accepts mode, accent, and tokens from the core and control groups (controlHeight 36, 44, or 50 px) plus accentStrong (selected label), shadowResting (soft pill elevation), and surfaceSunken. Supply application-wide defaults with UtherealProvider.

Composition

In agent compositions, Tabs is a container whose children are either empty (standalone tab bar) or exactly one TabPanel per tab value. Validation rejects compositions with missing, duplicate, or unmatched TabPanel children.

Selected tab state persists at /components/instance-<id>/value, initialized from defaultValue and reconciled to the initial tab if a live edit removes or disables the selected tab. See Building with agents.

{
  "root": "case",
  "elements": {
    "case": {
      "type": "Tabs",
      "props": {
        "label": "Case sections",
        "items": [
          { "value": "chat", "label": "Chat" },
          { "value": "sources", "label": "Sources" }
        ]
      },
      "children": ["chat-panel", "sources-panel"]
    },
    "chat-panel": {
      "type": "TabPanel",
      "props": { "value": "chat" },
      "children": ["question"]
    },
    "sources-panel": {
      "type": "TabPanel",
      "props": { "value": "sources" },
      "children": ["no-sources"]
    },
    "question": {
      "type": "TextInput",
      "props": { "label": "Ask about this case" },
      "children": []
    },
    "no-sources": {
      "type": "EmptyState",
      "props": { "title": "No sources yet" },
      "children": []
    }
  }
}

On this page