Skip to content

Tabs ​

Tab bar with keyboard navigation and panel content switching. Uses compound component pattern: Tabs > TabList + TabPanel.

Import ​

tsx
import { Tabs, TabList, Tab, TabPanel } from "silvery"

Tabs Props ​

PropTypeDefaultDescription
childrenReactNoderequiredTab children (TabList + TabPanel components)
defaultValuestring--Default active tab value (uncontrolled)
valuestring--Controlled active tab value
onChange(value: string) => void--Called when the active tab changes
isActivebooleantrueWhether tab input is active

TabList Props ​

PropTypeDefaultDescription
childrenReactNoderequiredTab children

Tab Props ​

PropTypeDefaultDescription
valuestringrequiredUnique tab identifier
childrenReactNoderequiredTab label content

TabPanel Props ​

PropTypeDefaultDescription
valuestringrequiredTab value this panel corresponds to
childrenReactNoderequiredPanel content

Keyboard Shortcuts ​

KeyAction
Right / lNext tab
Left / hPrevious tab

Usage ​

tsx
<Tabs defaultValue="general">
  <TabList>
    <Tab value="general">General</Tab>
    <Tab value="advanced">Advanced</Tab>
    <Tab value="about">About</Tab>
  </TabList>
  <TabPanel value="general">
    <Text>General settings...</Text>
  </TabPanel>
  <TabPanel value="advanced">
    <Text>Advanced settings...</Text>
  </TabPanel>
  <TabPanel value="about">
    <Text>About this app...</Text>
  </TabPanel>
</Tabs>

Rendering ​

Active tab is bold with $fg-accent color and underline. Inactive tabs use $fg-muted. TabPanel only renders children when the corresponding tab is active.

See Also ​