Switches between content panels on the same page. Use ToggleGroup to change a layout, filter or tool state, and Link to navigate to another page.
import { Tabs } from "@usememos/ui";
import { Bell, User } from "lucide-react";
<Tabs.Root defaultValue="account">
<Tabs.List aria-label="Settings sections">
<Tabs.Tab value="account" icon={<User />}>Account</Tabs.Tab>
<Tabs.Tab value="notifications" icon={<Bell />}>Notifications</Tabs.Tab>
</Tabs.List>
<Tabs.Panel value="account">…</Tabs.Panel>
<Tabs.Panel value="notifications">…</Tabs.Panel>
</Tabs.Root>| Part | Base UI part | Renders |
|---|---|---|
Tabs.Root |
Tabs.Root |
A <div> around the list and panels. Takes size |
Tabs.List |
Tabs.List with Tabs.Indicator |
The well, a <div role="tablist">, with the selected key built in |
Tabs.Tab |
Tabs.Tab |
One tab, a <button role="tab">. Takes icon |
Tabs.Panel |
Tabs.Panel |
One tab's content, a <div role="tabpanel"> |
interface Tabs.RootProps extends BaseTabs.Root.Props {
size?: "sm" | "md";
}
interface Tabs.TabProps extends BaseTabs.Tab.Props {
icon?: IconElement; // before the label
}Base UI's props pass through: value, defaultValue, onValueChange on the root; activateOnFocus, loopFocus on the list; value, disabled on each tab; keepMounted on each panel.
- Give the list an
aria-label. - Each tab activates a corresponding
Tabs.Panel, such as Account or Notifications. Use Tabs when the choices name content sections. - List / 2 / 3 / Auto changes how the same content is displayed: use a single-choice ToggleGroup. Do not add empty panels just to use Tabs' appearance for a setting.
- Tabs and single-choice ToggleGroups share one segmented treatment. Pick by what the control changes; do not create separate tokens or visual variants to distinguish them.
- Left and Right arrow keys move between tabs.
- Shares the quiet well and selected key with a single-choice ToggleGroup. Selection and label changes update immediately, without a slide or color fade. Normal selection uses a
keyfill without a visible border; hover only changes label and icon contrast. Focus reusesmu-focus, independently of selection. In forced colors the selected key retains its text-colored border. Use the standard sm and md size rows and the shared inset and radius tokens. - Tabs are sized to their labels and wrap when space is narrow; the well and key grow to fit. Tabs keep the same dimensions and hit boundaries for mouse and touch input. The key re-measures when a label changes width.
- Selected and hovered labels
text, otherstext-secondary. Weight never changes, so labels don't shift.