Skip to Content

Tabs

A compound component for tabbed navigation. State is managed internally — no external state machine required. Follows the WAI-ARIA Tabs pattern.

Usage

import { Tabs, TabList, Tab, TabPanel } from '@froglet/ui' <Tabs defaultValue="account"> <TabList> <Tab value="account">Account</Tab> <Tab value="password">Password</Tab> </TabList> <TabPanel value="account"> <p>Account settings go here.</p> </TabPanel> <TabPanel value="password"> <p>Password settings go here.</p> </TabPanel> </Tabs> // Controlled const [active, setActive] = useState('account') <Tabs value={active} onValueChange={setActive}> ... </Tabs>

Props

Tabs

PropTypeDefaultDescription
defaultValuestring""Uncontrolled initial active tab.
valuestringControlled active tab value.
onValueChange(value: string) => voidCalled when the active tab changes.
classNamestringAdditional CSS classes.
refReact.Ref<HTMLDivElement>Forwarded to the underlying <div>.

Tab

Extends ButtonHTMLAttributes<HTMLButtonElement>.

PropTypeDescription
valuestringRequired. Identifies this tab. Match a TabPanel.
classNamestringAdditional CSS classes.
refReact.Ref<HTMLButtonElement>Forwarded to the underlying <button>.

TabPanel

Extends HTMLAttributes<HTMLDivElement>.

PropTypeDescription
valuestringRequired. Identifies this panel. Match a Tab.
classNamestringAdditional CSS classes.
refReact.Ref<HTMLDivElement>Forwarded to the underlying <div>.

CSS Custom Properties

TokenDefaultDescription
--tabs-list-border-bottom-width1pxList bottom border width.
--tabs-list-border-bottom-colorcurrentColorList bottom border color.
--tabs-list-gap0Gap between tab buttons.
--tabs-tab-padding0.5rem 1remTab button padding.
--tabs-tab-font-size1remTab font size.
--tabs-tab-font-weight400Tab font weight (inactive).
--tabs-tab-font-weight-selected600Active tab font weight.
--tabs-tab-colorinheritTab text color (inactive).
--tabs-tab-color-selectedcurrentColorActive tab text color.
--tabs-tab-color-hoverinheritTab text color on hover.
--tabs-tab-border-bottom-width2pxActive indicator height.
--tabs-tab-border-bottom-color-selectedcurrentColorActive indicator color.
--tabs-tab-outline-width-focus2pxFocus outline width.
--tabs-tab-outline-color-focuscurrentColorFocus outline color.
--tabs-tab-outline-offset-focus2pxFocus outline offset.
--tabs-panel-padding1rem 0Panel padding.

Accessibility

  • Follows the WAI-ARIA Tabs pattern.
  • ArrowRight/ArrowLeft move between tabs; Home/End jump to first/last.
  • Inactive TabPanel elements receive the native hidden attribute — not focusable or announced by screen readers.
Last updated on