All specs
Interactive · tabs

Tabs

Interactive tab bar navigation with ←/→ selection.

Anatomy

▸ Overview   · Config   · Logs

←→ navigate · ↵ select · esc cancel

Usage

const tab = await tabs({
  items: [
    { label: 'Overview', value: 'overview' },
    { label: 'Config',   value: 'config' },
    { label: 'Logs',     value: 'logs' },
  ],
})

if (tab === 'config') { /* ... */ }

Options

KeyTypeDefaultDescription
items{ label, value }[]Tab items
defaultIndexnumber?0Initially selected tab
immediateboolean?falseReturn immediately on ←/→ (no Enter)

Keyboard

KeyAction
Previous tab
Next tab
tabNext tab
Confirm selection
escCancel → null

Do & don't

Do — use for switching between views or sections

Don't — use for selecting from a long list (use prompt.select); don't use as a form field (use prompt.select)

Out of scope

Vertical tab layout

Tab content rendering (compose yourself)

Closeable/draggable tabs

Overflow scrolling (keep tab count low)