Live demo
Demo source
Use tabs to switch between related views within a page. The tab strip keeps the available views visible, and an underline identifies the selected view. Your application supplies the content panels and keeps them aligned with the selected value.
Anatomy
A tab strip with seven callouts: 1 marks a tab item, 2 a leading icon, 3 a label, 4 a notification count, 5 a trailing icon, 6 the selected tab's underline, and 7 the full-width separator.
- Tab item (
nv-tabitem) represents one view in the group. - Leading icon optionally reinforces the view's meaning.
- Label is the visible name of the view.
- Notification optionally shows a count of new items.
- Trailing icon is optional supporting content.
- Active underline marks the tab selected by the container's
value. - Separator is the optional line beneath the full container, enabled
with
showSeparator. The active underline remains visible without it.
Composing tabs and panels
Place nv-tabitem children directly in nv-tabs. Give each item a unique
value, a visible label, and a panelId. The group owns selection; an item
has no public selected property.
| Design setting | Component API |
|---|---|
| Items | Default slot of nv-tabs, containing nv-tabitem children |
| Active view | value on the container matches the item's value |
| Unavailable view | disabled on the item |
| Full-width baseline | showSeparator on the container; off by default |
| Optional item content | leadingIcon, trailingIcon and notification |
Render each panel with role="tabpanel", an ID matching its tab's panelId,
and aria-labelledby pointing to that tab's ID. Update panel visibility from
the group's valueChanged event. A programmatic change to an available value
does not emit that event, so update the panels from the same application
state. The checked examples show the complete relationship in each framework.
The first enabled tab becomes selected when no available value is supplied.
If the selected tab is removed or disabled, the group selects the next
enabled tab, falling back to a previous one, and reports the changed value.
States and themes
Tabs have default, hover, selected and disabled appearances in Spark and
Ocean, in light and dark mode. Selection changes the label, icons and
underline together. A disabled item stays visible and cannot be activated.
Counts appear from 1; omitting notification or setting it to 0 hides them.
Layout and accessibility
Tabs are horizontal. Each label stays on one line; whole items wrap in source order when the container narrows. There is no scroll strip, overflow menu or vertical variant. Keep labels short and use icons and counts when they add meaning.
Name the tablist with aria-label or aria-labelledby. The group has one
Tab stop. Left and Right move focus between enabled tabs; Home and End reach
the first and last enabled tab. Enter or Space selects the focused tab.
Disabled tabs are skipped. Make the selected panel's content reachable next
in the keyboard sequence.
Decorative icons are hidden from assistive technology. Translate
notificationLabel to describe the count without replacing the tab's name;
{count} is replaced with the number. Keep the selected underline and the
keyboard focus indicator visible.
Use Navbar for destinations on different pages and Toggle button group for a setting or filter.