Skip to content
Nana UI

Navigation

Tab Group

Organises content into a row of tabs and matching panels, with full keyboard support, a sliding active indicator, and four placements.

View .md Download
First Second Panel one. Panel two.
General settings (underline)
General settings (pill)
General settings (segmented)

Install the package for a versioned dependency:

npm install @nana-tec/ui-components

Or copy the source in and own it:

npx @nana-tec/ui add tab-group --framework web-components
npx @nana-tec/ui add tabs --framework svelte

Lands in src/lib/components/ui/tabs/ as NanaTabs.svelte, NanaTabList.svelte, NanaTab.svelte and NanaTabPanel.svelte, styled with Tailwind classes that resolve to the design tokens. Requires Tailwind v4.

Import the autoloader once, in your app's entry point. Every <nana-*> tag then works anywhere, and each component downloads only the first time a page uses it:

import "@nana-tec/ui-components/autoloader";
import "@nana-tec/ui-components/theme";

The second line gives every component the Nana look and the design tokens behind it. Leave it out to style the components entirely yourself.

Import a component directly when it must be ready at once: on screen at first paint, or when you call its methods straight away. The two mix freely:

import "@nana-tec/ui-components/tab-group";

Copied in with npx @nana-tec/ui add tab-group? Import your project's own @/lib/nana-ui/autoloader.js once instead; the CLI keeps it up to date.

<nana-tab-group style="width:100%">
<nana-tab slot="nav" panel="a">First</nana-tab>
<nana-tab slot="nav" panel="b">Second</nana-tab>
<nana-tab-panel name="a">Panel one.</nana-tab-panel>
<nana-tab-panel name="b">Panel two.</nana-tab-panel>
</nana-tab-group>
<script lang="ts">
import { NanaTabs, NanaTabList, NanaTab, NanaTabPanel } from '$lib/components/ui/tabs';
let tab = $state('general');
</script>
<NanaTabs bind:value={tab} variant="segmented">
<NanaTabList>
<NanaTab value="general">General</NanaTab>
<NanaTab value="advanced">Advanced</NanaTab>
</NanaTabList>
<NanaTabPanel value="general">General content</NanaTabPanel>
<NanaTabPanel value="advanced">Advanced content</NanaTabPanel>
</NanaTabs>

value is $bindable and required. The list handles arrow keys, Home and End; only the selected panel is rendered.

The variant attribute sets the tab styling — underline (default), pill, segmented, filled, ghost, or card.

First Second Pill panel one. Pill panel two. First Second Segmented panel one. Segmented panel two. First Second Filled panel one. Filled panel two. First Second Card panel one. Card panel two. First Second Ghost panel one. Ghost panel two.

Set placement to top (default), bottom, start, or end.

First Second Panel one. Panel two.

Properties

PropertyAttributeTypeDefaultDescription
activationactivationTabGroupActivation'auto'auto activates a tab as it's focused; manual waits for Enter / Space / click.
noIndicatorno-indicatorbooleanfalseHide the sliding active indicator.
placementplacementTabGroupPlacement'top'Where the tabs sit relative to the panels.
sizesizeTabSize'md'Size applied to every tab in the group.
variantvariantTabVariant'underline'Visual style applied to every tab in the group.

Methods

MethodDescription
show(name: string): voidShow the panel (and tab) with the given name.

Events

EventDescription
nana-tab-showEmitted when a tab is shown (detail.name).
nana-tab-hideEmitted when a tab is hidden (detail.name).

Slots

SlotDescription
navThe nana-tab elements.
(default)The nana-tab-panel elements.

CSS parts

PartDescription
::part(base)The host container.
::part(nav)The tab navigation region.
::part(tablist)The scrollable tab list.
::part(indicator)The active-tab indicator.
::part(thumb)The segmented and pill variants' active thumb, which flows between tabs.
::part(body)The panel container.

CSS custom properties

PropertyDescription
--nana-tab-group-indicator-colorColour of the active indicator.
--nana-tab-group-border-colorColour of the divider line.
--nana-tab-group-track-bgSegmented variant's track fill. Defaults to a translucent tint of the text colour, so it reads on any surface; set an opaque colour to pin it.
--nana-tab-group-track-radiusCorner radius of the segmented / pill track. The active thumb derives its own radius from this so the two stay concentric.
--nana-tab-group-track-padInset between the track and the active thumb.
--nana-tab-group-indicator-sizeThickness of the active indicator bar
--nana-tab-active-bgFill of the segmented variant's thumb.
--nana-tab-thumb-bgTheme slot for the segmented thumb fill, set by the light and dark themes.
--nana-tab-thumb-lineTheme slot for the segmented thumb edge.

NanaTab

PropType
valuerequiredstring
childrenSnippet

Also accepts Omit< HTMLButtonAttributes, 'class' | 'value' >.

NanaTabPanel

PropType
valuerequiredstring
childrenSnippet

Also accepts Omit< HTMLAttributes<HTMLDivElement>, 'class' >.

NanaTabs

PropTypeDefault
valuerequiredbind:stringundefined
variantTabVariant'underline'
sizeTabSize'md'
orientationTabsOrientation'horizontal'
activationTabsActivation'auto'
onValueChange(value: string) => void
childrenSnippet

Also accepts Omit<HTMLAttributes<HTMLDivElement>, 'class'>.