Tabs
NavigationPanels shown one at a time, chosen with tabs: <Tabs.Root> (bind:value, orientation) holds a Tabs.List of Tabs.Triggers and a Tabs.Content per tab, matched by value. Arrow keys move between tabs and show their panel; Tab moves into the panel.
import { Tabs } from '@limerdev/zest'; Use for
Views of the same thing side by side on one page: a project's overview, hours and settings; a form split into a few sections.
Don't
Moving between pages: use links (a
NavigationMenu or a sidebar). Steps the user must go through in order. Many tabs that don't fit: use a Select or a sidebar.Examples
Basic
Views of one project. Arrow keys move between tabs.
Twelve people on three projects. Next invoice on 15 December.
412 hours logged this month, 380 billable.
Billing contact, rates and reminders.
<script lang="ts">
import { Tabs } from '@limerdev/zest';
</script>
<Tabs.Root value="overview" class="w-full max-w-md">
<Tabs.List aria-label="Project">
<Tabs.Trigger value="overview">Overview</Tabs.Trigger>
<Tabs.Trigger value="hours">Hours</Tabs.Trigger>
<Tabs.Trigger value="settings">Settings</Tabs.Trigger>
</Tabs.List>
<Tabs.Content value="overview" class="text-sm">
Twelve people on three projects. Next invoice on 15 December.
</Tabs.Content>
<Tabs.Content value="hours" class="text-sm">
412 hours logged this month, 380 billable.
</Tabs.Content>
<Tabs.Content value="settings" class="text-sm">
Billing contact, rates and reminders.
</Tabs.Content>
</Tabs.Root> Vertical
orientation="vertical" stacks the tabs beside the panels; Up and Down move.
Name, timezone and language.
The tabs keep their own height, however tall the panel beside them grows.
Each setting is saved as soon as it changes.
Invoice address and payment terms.
Who can log and approve hours.
<script lang="ts">
import { Tabs } from '@limerdev/zest';
</script>
<Tabs.Root value="general" orientation="vertical" class="w-full max-w-lg">
<Tabs.List aria-label="Settings">
<Tabs.Trigger value="general">General</Tabs.Trigger>
<Tabs.Trigger value="billing">Billing</Tabs.Trigger>
<Tabs.Trigger value="members">Members</Tabs.Trigger>
</Tabs.List>
<Tabs.Content value="general" class="flex flex-col gap-2 text-sm">
<p>Name, timezone and language.</p>
<p>The tabs keep their own height, however tall the panel beside them grows.</p>
<p>Each setting is saved as soon as it changes.</p>
</Tabs.Content>
<Tabs.Content value="billing" class="text-sm">Invoice address and payment terms.</Tabs.Content>
<Tabs.Content value="members" class="text-sm">Who can log and approve hours.</Tabs.Content>
</Tabs.Root> Props
Every part also takes class (merged over its defaults), ref (bindable: the element), children, and child (a snippet that
renders your own element, with props to spread on it).
Tabs.Root
| Prop | Type | Default | Description |
|---|---|---|---|
| activationMode | "manual" | "automatic" | "automatic" | How the tabs should be activated. If set to 'automatic', the tabs will be activated when the trigger is focused. If set to 'manual', the tabs will be activated when the trigger is pressed. |
| disabled | boolean | false | Whether the tabs are disabled or not. |
| loop | boolean | false | Whether to loop through the tabs when reaching the end when using the keyboard. |
| onValueChange | OnChangeFn<string> | โ | A callback function called when the selected tab changes. |
| orientation | "horizontal" | "vertical" | "horizontal" | The orientation of the tabs. |
| value bindable | string | '' | The value of the selected tab. |
Tabs.List
No props of its own beyond the common ones.
Tabs.Trigger
| Prop | Type | Default | Description |
|---|---|---|---|
| disabled | null | false | true | false | Whether the trigger is disabled or not. |
| value required | string | โ | The value of the tab associated with this trigger. |
Tabs.Content
| Prop | Type | Default | Description |
|---|---|---|---|
| value required | string | โ | The value of the tab associated with this content. |