@k8ordo/ui

Tabs

Switches content with tabs. Panels cross-fade, and the keyboard follows the WAI-ARIA tabs pattern.

Import

ts
import { Tabs } from '@k8ordo/ui';

Usage

Overview content goes here.

tsx
<Tabs.Root ids={['overview', 'settings', 'history']}>
  <Tabs.List label="Navigation">
    <Tabs.Tab id="overview">Overview</Tabs.Tab>
    <Tabs.Tab id="settings">Settings</Tabs.Tab>
    <Tabs.Tab id="history">History</Tabs.Tab>
  </Tabs.List>
  <Tabs.Panel id="overview">
    <p>Overview content goes here.</p>
  </Tabs.Panel>
  <Tabs.Panel id="settings">
    <p>Settings content goes here.</p>
  </Tabs.Panel>
  <Tabs.Panel id="history">
    <p>History content goes here.</p>
  </Tabs.Panel>
</Tabs.Root>

Default selection

Settings content goes here.

tsx
<Tabs.Root
  defaultSelectedId="settings"
  ids={['overview', 'settings', 'history']}
>
  <Tabs.List label="Navigation">
    <Tabs.Tab id="overview">Overview</Tabs.Tab>
    <Tabs.Tab id="settings">Settings</Tabs.Tab>
    <Tabs.Tab id="history">History</Tabs.Tab>
  </Tabs.List>
  <Tabs.Panel id="overview">
    <p>Overview content goes here.</p>
  </Tabs.Panel>
  <Tabs.Panel id="settings">
    <p>Settings content goes here.</p>
  </Tabs.Panel>
  <Tabs.Panel id="history">
    <p>History content goes here.</p>
  </Tabs.Panel>
</Tabs.Root>

Props

Tabs.Root

ids
Type: [string, ...string[]]
Default: -
children?
Type: ReactNode
Default: -
defaultSelectedId?
Type: string|null
Default: null
onChange?
Type: (id: string) => void
Default: -
selectedId?
Type: string
Default: -
PropTypeDefault
ids[string, ...string[]]-
children?ReactNode-
defaultSelectedId?string|nullnull
onChange?(id: string) => void-
selectedId?string-

Tabs.List

label
Type: string
Default: -
children?
Type: ReactNode
Default: -
PropTypeDefault
labelstring-
children?ReactNode-

Tabs.Tab

id
Type: string
Default: -
children?
Type: ReactNode
Default: -
PropTypeDefault
idstring-
children?ReactNode-

Tabs.Panel

id
Type: string
Default: -
children?
Type: ReactNode
Default: -
PropTypeDefault
idstring-
children?ReactNode-
k8ordo

React libraries that use Baseline features without holding back.