Navigation Core Stable

Tabs

A tablist compound with roving-tabindex keyboard navigation, automatic or manual activation, and an accent-underline or segmented visual style.

Preview

Installation

pnpm add fancy-ui-svelte
import { Tabs } from 'fancy-ui-svelte'

Usage

svelte
<script lang="ts">
  import { Tabs } from 'fancy-ui-svelte';
</script>

<Tabs />

Examples

Basic Usage

Three tabs, automatic activation, the underline variant.

Segmented Variant

The pill-rail visual style instead of the accent underline.

Manual Activation

Arrow keys only move focus; Enter/Space or a click selects.

Vertical Tabs

Stacked in a column, with Up/Down driving the roving tabindex.

Disabled Tab

One trigger unavailable — skipped by the arrows and Home/End.

Props

PropTypeDefaultDescription
value string""The active tab's value, bindable.
onValueChange (value: string) => void-Called with the new value whenever the active tab changes.
orientation "horizontal" | "vertical""horizontal"The tablist's stacking axis and which arrow-key pair moves it.
activation "automatic" | "manual""automatic"Whether arrowing to a trigger selects it immediately, or only moves focus.
variant "underline" | "segmented""underline"Accent underline, or a segmented pill rail.
class string-Additional CSS classes, merged onto the root.
ref HTMLDivElement | nullnullBindable reference to the root element.
TabsList.class string-Additional CSS classes, merged onto the tablist.
TabsList.ref HTMLDivElement | nullnullBindable reference to the tablist element.
TabsTrigger.value *string-This trigger's value — which TabsContent it activates.
TabsTrigger.disabled booleanfalseDisables just this trigger; it is skipped by the arrows and Home/End.
TabsTrigger.class string-Additional CSS classes, merged onto the trigger button.
TabsTrigger.ref HTMLButtonElement | nullnullBindable reference to the trigger's button element.
TabsContent.value *string-Which TabsTrigger shows this panel.
TabsContent.forceMount booleanfalseKeeps this panel mounted (with hidden) even while inactive, instead of unmounting it entirely.
TabsContent.class string-Additional CSS classes, merged onto the panel.
TabsContent.ref HTMLDivElement | nullnullBindable reference to the panel element.

Slots

SlotDescription
childrenA TabsList and one or more TabsContents.
TabsList.childrenThe TabsTriggers.
TabsTrigger.childrenThe trigger's content, typically the tab's label.
TabsContent.childrenThe panel's content.