Skip to content
Nana UI

Tab

View .md Download

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.

Overview Activity Overview panel. Activity panel.
Terminal window
npm install @nana-tec/ui-components
import "@nana-tec/ui-components/tab";
<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
activebooleanfalseWhether the tab is the active/selected one (managed by the group).
closablebooleanfalseShow a close button.
countstring | number | undefinedOptional count shown as a small badge after the label.
disabledbooleanfalseDisable the tab.
panelstring''The name of the panel this tab controls (matches a panel's `name`).
sizeTabSize'md'Tab size. Usually set automatically by the parent `nana-tab-group`.
variantTabVariant'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-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.
EventTypeDescription
nana-tab-closeCustomEventEmitted when the tab is closed via the button or Delete / Backspace (detail.panel).
SlotDescription
(default)The tab’s label.
prefixContent before the label, typically an icon.
suffixContent after the label, e.g. a count badge.
VariableDefaultDescription
--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.
PartDescription
baseThe tab’s inner container
countThe built-in count badge
close-buttonThe close button
Explore Tab interactively Every state, prop, and edge case — with live controls — in Storybook.
View in Storybook