Skip to content

Tabs

Switch between views in place: underline, pill and button styles, a sidebar-style vertical list, icons and counts, and a sliding indicator. Arrow keys move.

On this page
Used for
  • Run logs and output
  • Settings sections
  • Ticket views
  • Agent trace modes

Examples

Variant
Size
Activation

Installation

npx knowns-ui@latest add tabs
For Claude Code, Cursor or Codex: installs it and wires the props to your own data.

Props

Tabs.value / defaultValue
string
Controlled or uncontrolled selected tab.
Tabs.onValueChange
(value: string) => void
Called when a different tab is selected.
Tabs.variant
"underline" | "pill" | "button"
Default"underline"
A line under the active tab, a raised pill on a muted track, or joined bordered segments. The indicator slides between tabs (transform, ease-out; off with reduced motion).
Tabs.size
"sm" | "md"
Default"md"
Underline 32 / 36px, pill 24 / 28px (+ track), button 28 / 32px.
Tabs.orientation
"horizontal" | "vertical"
Default"horizontal"
Vertical puts the list beside the panels like a sidebar; ↑ ↓ move, aria-orientation is set.
Tabs.activationMode
"automatic" | "manual"
Default"automatic"
Automatic: arrows move focus and select. Manual: arrows move focus; Enter or Space selects.
Tabs.fullWidth
boolean
Defaultfalse
Horizontal tabs share the full width equally.
Tabs.links
boolean
Defaultfalse
Link mode for tabs that are routes. Triggers with an href render as links (Ctrl or Cmd click opens a new tab), the list is a nav landmark named by TabsList's aria-label, the current link has aria-current="page", and there is no tablist, tab role or arrow roving.
TabsList
{ aria-label | aria-labelledby, variant?, size?, fullWidth?, flush?, className? }
Names the tablist; can override Tabs' look. Scrolls sideways when tabs don't fit, fading the clipped edges; the selected tab is kept in view.
TabsTrigger
{ value, children, icon?, badge?, disabled?, href?, onClick?, className? }
One tab. badge shows a count or short text after the label and is read as part of its name. Disabled tabs are skipped by the arrows.
TabsContent
{ value, children, keepMounted?, className? }
The panel for that value, linked to its tab. keepMounted keeps it in the DOM (hidden) so its state survives.
Keys
← → (↑ ↓ vertical), Home, End
Wrap around and skip disabled tabs. Only the selected tab is in the Tab order.

What it handles

  1. 01Builds Tabs, TabsList, TabsTrigger and TabsPanel parts in three looks through variant: underline, pill and button.
  2. 02Moves with the arrow keys for the orientation (Left and Right, or Up and Down when vertical, mirrored in right-to-left text), plus Home and End, skipping disabled tabs.
  3. 03Selects as focus moves in automatic activation, or only on Enter and Space in manual, set by activationMode.
  4. 04Slides one indicator between tabs, measured from the real tab boxes, and re-measures when a tab resizes.
  5. 05Scrolls a long horizontal list, fades the clipped ends with a mask, and brings the selected tab back into view.
  6. 06Adds an icon and a badge count to a trigger, and keepMounted holds a hidden panel in the DOM so its state survives.

States

First render
Nothing. The indicator sits on the selected tab with no slide
none
Selection changes
The indicator slides and resizes to the new tab
180ms, ease out
Tab hover
The tab text colour changes
120ms, ease out
Panel switch
The old panel is hidden and the new one shows at once
none
Reduced motion
The indicator jumps to the new tab
0ms

Works with

When to use

When to use

  • Switching between panels of related content on one page.

When not to use

Using with AI

Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:

  • Add the Knowns UI Tabs to my app and wire it to my own data.
  • I need switching between panels of related content on one page. Set that up with the Knowns UI Tabs.
  • Which Tabs props do I need for a minimal setup? Show me a short example.

With the server connected, your assistant calls get_component({ name: "tabs" }) and search_docs({ query: "tabs" }).

Need help?

Stuck on Tabs, or found something off? We read every message.