Tabs
Basic
Manage your account details and preferences.
Update your password and security settings.
Configure notifications and display options.
tabs-basic.tsx
import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs"
export function TabsBasic() {
return (
<Tabs defaultValue="account">
<TabsList>
<TabsTrigger value="account"><p className="text-sm">Account</p></TabsTrigger>
<TabsTrigger value="password"><p className="text-sm">Password</p></TabsTrigger>
<TabsTrigger value="settings"><p className="text-sm">Settings</p></TabsTrigger>
</TabsList>
<TabsContent value="account"><p className="text-sm">Manage your account details and preferences.</p></TabsContent>
<TabsContent value="password"><p className="text-sm">Update your password and security settings.</p></TabsContent>
<TabsContent value="settings"><p className="text-sm">Configure notifications and display options.</p></TabsContent>
</Tabs>
)
}
Controlled mode
Section titled “Controlled mode”Parent owns value and onValueChange (React) or uses bind:value (Svelte). The state-layer atom mirrors the prop bidirectionally — clicks update parent state; parent updates flow back into the active tab.
React
Svelte
Uncontrolled (live)
Section titled “Uncontrolled (live)”Same state-layer atom drives both — React reads via useSyncExternalStore, Svelte via context + store-protocol bridge.