Skip to content
Nana UI

Navigation

Tab

A single tab within a nana-tab-group. Place tabs in the group's nav slot and link each to a panel via the panel attribute. The host element is the focusable tab (role="tab"), so assistive tech and the group's roving-tabindex navigation operate on a single element.

View .md Download

In Svelte this is NanaTab, installed with the tabs. See Tab Group.

Overview Activity Overview panel. Activity panel.
npm install @nana-tec/ui-components

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";

Copied in with npx @nana-tec/ui add tab? 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">Tab</nana-tab>
<nana-tab-panel name="a">Panel.</nana-tab-panel>
</nana-tab-group>

Add a count badge to a tab.

Inbox Drafts Inbox panel. Drafts panel.

Add closable to show a close button on a tab.

Overview Settings Overview panel. Settings panel.

Properties

PropertyAttributeTypeDefaultDescription
activeactivebooleanfalseWhether the tab is the active/selected one (managed by the group).
closableclosablebooleanfalseShow a close button.
countcountstring | number | undefined—Optional count shown as a small badge after the label.
disableddisabledbooleanfalseDisable the tab.
panelpanelstring''The name of the panel this tab controls (matches a panel's name).
sizesizeTabSize'md'Tab size. Usually set automatically by the parent nana-tab-group.
variantvariantTabVariant'underline'Visual style. Usually set automatically by the parent nana-tab-group.

Events

EventDescription
nana-tab-closeEmitted when the tab is closed via the button or Delete / Backspace (detail.panel).

Slots

SlotDescription
(default)The tab's label.
prefixContent before the label, typically an icon.
suffixContent after the label, e.g. a count badge.

CSS parts

PartDescription
::part(base)The tab's inner container.
::part(count)The built-in count badge.
::part(close-button)The close button (when closable).

CSS custom properties

PropertyDescription
--nana-tab-hover-bgHover fill for the pill, filled and ghost variants. Defaults to a translucent tint of the text colour, so it reads on any surface; set an opaque colour to pin it.
--nana-tab-active-bgFill of the active thumb in the segmented variant.
--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.
--nana-tab-inactive-colorLabel colour of an unselected tab. Defaults to the muted text step, which clears 4.5:1 on the segmented track; check contrast before recessing it further.
--nana-tab-group-track-padRead from the group so the active thumb stays concentric with the track
--nana-tab-group-track-radiusRead from the group so the active thumb stays concentric with the track