cnippet/ui
  1. ui
  2. navigation
  3. tabs

navigation

Tabs

A component for toggling between related panels on the same page. Built with Base UI and Tailwind CSS. Copy-paste ready.

API Reference

Installation

Usage

Anatomy

Good to know

  • TabsTrigger and TabsContent are aliases of TabsTab and TabsPanel. Prefer TabsTab and TabsPanel.
  • Every TabsTab needs a value, and each TabsPanel uses the same value as its tab.
  • Always set defaultValue (or value) on Tabs to one of your tab values. Base UI's default is 0, which doesn't match string values, so no tab would be selected.
  • TabsList accepts variant="default" (pill) or "underline". The moving indicator is rendered for you.
  • Arrow keys move focus between tabs; Enter or Space selects one. To select on focus, set activateOnFocus on TabsList.
  • Inactive panels are removed from the DOM. Set keepMounted on a TabsPanel to keep it rendered, for example to preserve form input.
  • orientation="vertical" on Tabs stacks the tabs and switches to up and down arrow keys.

API Reference

Tabs

Root container that manages tab state. Wraps Base UI Tabs.Root.

TabsList

Tab trigger strip. Renders the animated indicator internally.

TabsTab

Individual tab trigger. Also exported as TabsTrigger.

TabsPanel

Content panel shown when its tab is active. Also exported as TabsContent.

Examples

Underline Variant

Replaces the default pill indicator with an animated underline beneath the active tab for a lighter visual style.

Vertical Orientation

Renders tab triggers in a vertical column on the left with panels to the right, suited for settings or sidebar navigation.

Underline Vertical

Combines the underline indicator style with vertical orientation, placing the animated underline on the active tab's side edge.

In Card

Embeds the tab list inside a Card header with an input or action in the same row for a compact dashboard widget layout.

Line Style

A clean underline-style tab variant with a bottom border indicator for a minimal, text-forward presentation.

Vertical Orientation

A vertically oriented tab layout with panel content rendered beside the tab list for multi-section navigation.

Line Vertical

Underline indicator combined with vertical tab orientation for a refined side-navigation look.

With Icons

Adds a leading icon to each tab trigger for quicker visual identification alongside the label text.

With Badge Counts

Appends a numeric Badge to each tab label to show item counts such as unread messages or pending tasks.

Icons With Line

Combines leading icons with the line/underline style variant for an icon-forward, minimal tab strip.

Segmented Control

Renders tabs as a segmented control — a pill background slides between options — suited for binary or small option sets.

Settings Navigation

A vertical underline tab layout for a settings page with profile, security, notifications, and integrations panels. The active tab animates a left-edge underline indicator.

Code File Viewer

Per-file tabs styled like an editor tab bar. The active file's content appears below; a copy button in the header writes the current file's code to the clipboard.

Profile Repositories

Underline-style tabs with numeric badge counts for Repositories and Stars. The Repositories panel lists each repo with language dot, star count, and a Public badge.

Pricing Toggle

A segmented Monthly / Yearly billing toggle with a "Save 20%" badge on the yearly tab. Switching recalculates all plan prices in the card grid below without remounting.

Dashboard Metrics

Icon tabs for Analytics, Reports, Exports, and Activity. The Analytics panel shows a two-column grid of metric cards; other panels render contextual placeholder content.