Skip to content

Tabs ​

Tabs for the sections of one screen.

Fjord dresser and Nord table lamp for $368.

Bind the open tab with v-model: it holds the value of that tab.

Installation ​

ts
import { NuiTab, NuiTabList, NuiTabPanel, NuiTabs } from '@numior/kit';

Usage ​

Change the look, size and orientation of the tabs and the way arrow keys open them.

  • Order 20406, Evan Porter
  • Order 20407, Mary Cooper
  • Order 20408, Paul Hawkins
activation
automatic opens a tab on arrow keys, manual only moves focus until Enter.
orientation
Lays out the tabs in a row or a column.
variant
Style: line underlines the selected tab, soft gives it a background.
size
Changes the size of the tabs: sm, md or lg. The theme density shifts the height of each size.

Label of the tab list or the navigation for screen readers.

Examples ​

Build tabs from data ​

Pass a tabs array and render the panels in the panel slot.

  • Nord table lamp, 41 in stock
  • Arc floor lamp, 18 in stock
  • Sphere pendant, 22 in stock

Without the slot the tabs only switch: v-model gets the chosen tab, and your app decides what to show.

Close tabs ​

Add closable and remove the tab from your list in the close handler.

Evan Porter, Seattle, $199.

A tab closes with its button, a middle click or Delete. Tabs from tabs take closable in their descriptor, and NuiTabs then fires close with the value of the tab.

Pass links.

Each tab becomes a link to its to and renders like a Link with to. v-model holds the key of the current page: a string to is its own key, and getKey builds one from a route object. A click without modifier keys updates the model.

Behavior ​

Arrow keys wrap around and skip disabled tabs. Without a v-model value no tab is open.

When the tabs do not fit, the list scrolls with a swipe, the mouse wheel and the arrow buttons at its edges. A button shows up only at the edge that hides tabs. While the list can still scroll in the direction of the wheel, the page does not scroll.

The open tab and the focused tab always scroll into view. A vertical list does not scroll.

Hidden panels stay in the markup. With lazy, a panel renders the first time its tab opens.

The underline and the background follow the open tab when a label changes or tabs come and go. When the focused tab closes, the focus moves to the open one. A disabled tab cannot be closed.

Accessibility ​

Only the open tab is in the Tab order. Arrow keys open the next tab at once; with activation="manual" they only move the focus, and Enter or Space opens the tab.

A screen reader does not see the close button, because a tab list may hold only tabs. Delete closes the focused tab, as the WAI-ARIA pattern suggests.

A panel takes the focus on Tab, so the user reaches its text from the keyboard. When a panel always starts with a button or a link, remove that stop with :focusable="false".

Tabs from tabs without the panel slot have no panels, so they get no aria-controls.

Link tabs are a nav labeled by label, with plain links in place of tabs. The current page gets aria-current="page". Every link is in the Tab order, and arrow keys do not move between them.

Keys
Action
→
Moves to the next tab in a row.
←
Moves to the previous tab in a row.
↓
Moves to the next tab in a column.
↑
Moves to the previous tab in a column.
Home
Moves to the first tab.
End
Moves to the last tab.
⌦
Closes a closable tab.
↵
Opens the focused tab when activation is manual.
Space
Opens the focused tab when activation is manual.

API ​

NuiTabs

Props

Name
Type
Default
Description
id
string
—
Id of the tabs. Generated automatically by default.
activation
NuiTabsActivation
"automatic"
automatic opens a tab on arrow keys, manual only moves focus until Enter.
orientation
NuiTabsOrientation
"horizontal"
Lays out the tabs in a row or a column.
variant
NuiTabsVariant
"line"
Style: line underlines the selected tab, soft gives it a background.
size
NuiSize
"md"
Changes the size of the tabs: sm, md or lg. The theme density shifts the height of each size.
lazy
boolean
false
Renders a panel only when its tab is opened for the first time.
tabs
readonly NuiTabDescriptor[]
—
Tabs as an array instead of NuiTabList and NuiTab.
links
readonly NuiTabLinkDescriptor[]
—
Link tabs as an array of to, label, icon and disabled. Renders a nav of links instead of a tab list.
getKey
NuiTabLinkKey
defaultOptionKey
Key of a link tab from its to. A string address is its own key by default.
as
string | Component
—
Link component for links instead of the shared kit helper.
label
string
—
Label of the tab list or the navigation for screen readers.

Models

Name
Type
Default
Description
v-model
string
—
value of the selected tab or the key of the current link tab.

Events

Name
Payload
Description
close
[value: string]
Fires when a tab from tabs is closed, with its value.

Slots

Name
Slot props
Description
default
any
A NuiTabList and NuiTabPanel panels.
panel
NuiTabsPanelSlot
Panel content for a tab from tabs. Receives tab.

NuiTabList

Props

Name
Type
Default
Description
label
string
—
Label of the tab list for screen readers.

Slots

Name
Slot props
Description
default
{}
NuiTab tabs.

NuiTab

Props

Name
Type
Default
Description
valuerequired
string
—
Value of the tab that v-model receives.
icon
IconSource
—
Icon before the label, such as settings.
disabled
boolean
false
Disables the tab: it stays visible but cannot be opened or closed.
closable
boolean
false
Shows a close button. The tab closes with it, the middle mouse button or the Delete key.

Events

Name
Payload
Description
close
[]
Fires when the tab is closed. Remove it from the list yourself.

Slots

Name
Slot props
Description
default
{}
Text of the tab.

NuiTabPanel

Props

Name
Type
Default
Description
valuerequired
string
—
value of the tab the panel belongs to.
lazy
boolean
—
Renders the content only when the panel is opened for the first time.
focusable
boolean
true
Makes the panel reachable with Tab. Turn it off when the panel always holds buttons or links.

Slots

Name
Slot props
Description
default
{}
Content of the panel.

Edit this page

Search

Esc