Skip to content

Tabs

Tab switching component with a sliding indicator.

Basic Usage

tsx
import { Tabs } from '@airo-ui/react'
import { useState } from 'react'

function Demo() {
  const [activeKey, setActiveKey] = useState('1')

  return (
    <Tabs activeKey={activeKey} onChange={setActiveKey}>
      <Tabs.Pane tabKey="1" tab="Users">
        Users content
      </Tabs.Pane>
      <Tabs.Pane tabKey="2" tab="Settings">
        Settings content
      </Tabs.Pane>
      <Tabs.Pane tabKey="3" tab="Roles">
        Roles content
      </Tabs.Pane>
    </Tabs>
  )
}

Default Active Tab

Use defaultActiveKey for uncontrolled usage.

tsx
<Tabs defaultActiveKey="1">
  <Tabs.Pane tabKey="1" tab="Users">
    Users content
  </Tabs.Pane>
  <Tabs.Pane tabKey="2" tab="Settings">
    Settings content
  </Tabs.Pane>
</Tabs>

API

Tabs Props

NameTypeDefaultDescription
activeKeystring--Controlled active tab key
defaultActiveKeystring--Default active tab (uncontrolled)
onChange(key: string) => void--Active tab change handler
childrenReact.ReactNode--TabPane elements

TabPane Props

NameTypeDefaultDescription
tabKeystringRequiredUnique identifier
tabstringRequiredTab title text
childrenReact.ReactNode--Tab content

Interaction

  • Tab indicator follows with spring elastic transition
  • Content fade-in animation on switch
  • Full ARIA tab roles

MIT License