Tabs
Installation
npx @mielui/svelte add tabsyarn dlx @mielui/svelte add tabsbunx @mielui/svelte add tabsUsage
Bind value on Root to the selected tab. Each Trigger's value matches the Content panel it shows. When value matches no enabled trigger, the first enabled trigger is selected and onValueChange reports it.
<script lang="ts">
import * as Tabs from '@mielui/svelte/components/tabs';
let tab = $state('account');
</script>
<Tabs.Root bind:value={tab}>
<Tabs.List>
<Tabs.Trigger value="account">Account</Tabs.Trigger>
<Tabs.Trigger value="password">Password</Tabs.Trigger>
</Tabs.List>
<Tabs.Content value="account">Account settings</Tabs.Content>
<Tabs.Content value="password">Password settings</Tabs.Content>
</Tabs.Root>Arrow keys move between tabs along the orientation and wrap at the ends. Home and End jump to the first and last enabled tab. Focusing a tab selects it unless activationMode is manual. Inactive panels unmount unless their Content sets forceMount. Give List an aria-label when nothing nearby names the tabs.
Examples
Panels
Each tab shows its own panel. A grid on List stretches the tabs to full width.
Project overview
Everything is up to date.
Default
Ghost
Segmented
Vertical
orientation="vertical" stacks the tabs beside the panel. Up and Down Arrow move between them.
Account
Manage your profile and contact details.
Manual activation and kept state
With activationMode="manual", arrow keys move focus and Enter or Space selects. The Draft panel sets forceMount, so its input keeps its text while hidden. History is disabled.
API reference
Tabs.Root
Manages active tab state.
activationMode"automatic" | "manual"automaticselects a tab on focus.manualwaits for Enter or Space.Default
'automatic'valueBindablestringSelected tab. Bindable.
Default
''onValueChange((value: string) => void)Called with the new value when it changes.
orientation"horizontal" | "vertical"Direction of the tab list. It also sets which arrow keys move between tabs.
Default
'horizontal'variantTabsVariantStyle of the tab list.
Default
'default'classstringClasses added to the element.
childrenSnippet<[]>Content rendered inside.
Tabs.Content
Renders a tab panel.
valueRequiredstringIdentifies the panel. It matches a trigger's value.
forceMountbooleanKeeps the panel mounted while hidden, so its state survives.
Default
falseclassstringClasses added to the element.
childrenSnippet<[]>Content rendered inside.
Tabs.List
Groups tab triggers.
classstringClasses added to the element.
childrenSnippet<[]>Content rendered inside.
idstringId of the tab list element.
aria-labelstringAccessible name for the tab list.
aria-labelledbystringId of the element that names the tab list.
Tabs.Trigger
Selects a tab panel.
valueRequiredstringIdentifies the tab. It matches a panel's value.
disabledbooleanPrevents interaction and dims the control.
Default
falseclassstringClasses added to the element.
childrenSnippet<[]>Content rendered inside.
pnpm dlx @mielui/svelte add tabs