Tabs

Panels shown one at a time, switched by a person or an agent.

Source
$npx @dinachi/cli@latest add tabs

Account

Manage your account settings and preferences.

orientation
activateOnFocus
TabsIndicator
disabled

Usage

import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"

export function AccountTabs() {
  return (
    <Tabs defaultValue="account">
      <TabsList>
        <TabsTrigger value="account">Account</TabsTrigger>
        <TabsTrigger value="password">Password</TabsTrigger>
      </TabsList>
      <TabsContent value="account">Manage your account.</TabsContent>
      <TabsContent value="password">Change your password.</TabsContent>
    </Tabs>
  )
}

Examples

Account

Manage your account settings and preferences.

Three panels, one showing at a time.
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs';

export function Example() {
  return (
    <Tabs defaultValue="account" className="w-full max-w-md">
      <TabsList>
        <TabsTrigger value="account">Account</TabsTrigger>
        <TabsTrigger value="password">Password</TabsTrigger>
        <TabsTrigger value="settings">Settings</TabsTrigger>
      </TabsList>
      <TabsContent value="account" className="space-y-2 pt-4">
        <h3 className="text-sm font-medium">Account</h3>
        <p className="text-sm text-muted-foreground">
          Manage your account settings and preferences.
        </p>
      </TabsContent>
      <TabsContent value="password" className="space-y-2 pt-4">
        <h3 className="text-sm font-medium">Password</h3>
        <p className="text-sm text-muted-foreground">
          Change your password and security settings.
        </p>
      </TabsContent>
      <TabsContent value="settings" className="space-y-2 pt-4">
        <h3 className="text-sm font-medium">Settings</h3>
        <p className="text-sm text-muted-foreground">
          Configure your application preferences.
        </p>
      </TabsContent>
    </Tabs>
  );
}

Notes

Automatic changes

Uncontrolled Tabs pick a fallback when the active tab is missing or disabled, calling onValueChange with details.reason "initial", "missing" or "disabled". These cannot be cancelled.

API

valueValue
Controlled active tab. null shows none.
defaultValueValue = 0
Starting tab when uncontrolled.
onValueChange
agent
(value, details) => void
Runs for people and agents. details.cancel() refuses the change.
orientation"horizontal" | "vertical" = "horizontal"
Which arrow keys move between tabs.
aria-label
agent
string
Names the tabs for the agent. Defaults to tabs.

Agent

Inside an AgentProvider, it appears in agent.snapshot() as tabs.

Reads

label

The Tabs' aria-label, or tabs.

value

The active tab's label.

items

Every tab's label, in order.

disabled

True when every tab is disabled.

Actions

select("Password")

Selects by label, then value. A miss lists the tabs; disabled tabs are refused.

An agent's choice clicks the tab and reaches onValueChange with the agent's details. isAgentChange(details) is true for it; details.cancel() refuses it and the agent is told. Disabled tabs refuse on their own.

await agent.act({
  steps: [{ ref: "tabs", action: "select", args: ["Password"] }],
})

Accessibility

  • Tablist, tabs with aria-selected, and tabpanels labelled by their tab.
  • With several tab sets on a page, give each an aria-label.
  • Disabled tabs stay focusable and announced.
  • Hidden panels leave the DOM unless keepMounted is set.