Components
Tabs

Tabs

The Tabs component provides you with tab navigation and sections.

Import

import { Tabs, TabsList, TabsTrigger, TabsContent } from '@nostromo/ui-core'
// or
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@nostromo/ui-core/tabs'

Usage

import { Tabs, TabsList, TabsTrigger, TabsContent } from '@nostromo/ui-core'
 
export default function Example() {
  return (
    <Tabs defaultValue="account">
      <TabsList>
        <TabsTrigger value="account">Account</TabsTrigger>
        <TabsTrigger value="password">Password</TabsTrigger>
      </TabsList>
      <TabsContent value="account">
        <p>Account settings</p>
      </TabsContent>
      <TabsContent value="password">
        <p>Password settings</p>
      </TabsContent>
    </Tabs>
  )
}

Live Examples

Live Example
☀️
Copy
Storybook →
View Code
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@nostromo/ui-core' export default function TabsExample() { return ( <Tabs defaultValue="account" className="w-[400px]"> <TabsList> <TabsTrigger value="account">Account</TabsTrigger> <TabsTrigger value="password">Password</TabsTrigger> </TabsList> <TabsContent value="account">...

Accessibility

Keyboard Navigation

  • Arrow Keys: Navigate between tabs
  • Tab: Moves focus to tab content
  • Enter/Space: Activates the focused tab
  • Home/End: Moves to first/last tab

ARIA Attributes

  • role="tablist": Identifies the tab container
  • role="tab": Identifies individual tabs
  • role="tabpanel": Identifies tab content
  • aria-selected: Indicates the active tab
  • aria-controls: Links tabs to their content panels

Focus Management

  • Roving tabindex: Only one tab is focusable at a time
  • Focus indicators: Clear visual focus states
  • Focus restoration: Maintains focus when switching tabs

Screen Reader Support

  • Tab announcements: Active tab is announced
  • Content changes: Tab content changes are announced
  • Navigation hints: Keyboard navigation is described

Examples

// Accessible tabs with proper labeling
<Tabs defaultValue="account" className="w-[400px]">
  <TabsList aria-label="Account settings">
    <TabsTrigger value="account" aria-controls="account-panel">
      Account
    </TabsTrigger>
    <TabsTrigger value="password" aria-controls="password-panel">
      Password
    </TabsTrigger>
  </TabsList>
  <TabsContent value="account" id="account-panel" role="tabpanel">
    <p>Account content here.</p>
  </TabsContent>
  <TabsContent value="password" id="password-panel" role="tabpanel">
    <p>Password content here.</p>
  </TabsContent>
</Tabs>

Props

Tabs

PropTypeDefaultRequiredDescription
defaultValuestringundefinedNoDefault active tab value (uncontrolled)
valuestringundefinedNoActive tab value (controlled)
onValueChange(value: string) => voidundefinedNoCallback when active tab changes
orientation"horizontal" | "vertical""horizontal"NoTab orientation
dir"ltr" | "rtl""ltr"NoText direction
classNamestringundefinedNoAdditional CSS classes
childrenReact.ReactNodeundefinedNoTab content (TabsList, TabsContent)

TabsList

PropTypeDefaultRequiredDescription
variant"default" | "pills" | "underline""default"NoVisual variant
size"sm" | "default" | "lg""default"NoSize of tabs
classNamestringundefinedNoAdditional CSS classes
childrenReact.ReactNodeundefinedNoTab triggers

TabsTrigger

PropTypeDefaultRequiredDescription
valuestring-YesUnique value for this tab
disabledbooleanfalseNoWhether the tab is disabled
classNamestringundefinedNoAdditional CSS classes
childrenReact.ReactNodeundefinedNoTab label content
asChildbooleanfalseNoRender as child element

TabsContent

PropTypeDefaultRequiredDescription
valuestring-YesValue matching the corresponding TabsTrigger
forceMountbooleanfalseNoForce mount content even when inactive
classNamestringundefinedNoAdditional CSS classes
childrenReact.ReactNodeundefinedNoTab panel content