Tabs

Alpha

An accessible tab interface with automatic keyboard navigation and compound component API.

Import

import { Tabs } from "@compa11y/react";

Usage

Example.tsx
import { Tabs } from "@compa11y/react";

function Example() {
  return (
    <Tabs defaultValue="react">
      <Tabs.List aria-label="Framework">
        <Tabs.Tab value="react">React</Tabs.Tab>
        <Tabs.Tab value="vue">Vue</Tabs.Tab>
        <Tabs.Tab value="svelte">Svelte</Tabs.Tab>
      </Tabs.List>
      <Tabs.Panel value="react">
        React content goes here.
      </Tabs.Panel>
      <Tabs.Panel value="vue">
        Vue content goes here.
      </Tabs.Panel>
      <Tabs.Panel value="svelte">
        Svelte content goes here.
      </Tabs.Panel>
    </Tabs>
  );
}

Features

  • Arrow key navigation between tabs
  • Automatic tab activation
  • Compound component API
  • ARIA tabs pattern compliant
  • Proper role and aria attributes

Props

Tabs component props
PropTypeDefaultDescription
defaultValuestring-Initially selected tab value
valuestring-Controlled selected tab value
onValueChange(value: string) => void-Called when selected tab changes

Sub-components

Tabs.List

Tabs.List props
PropTypeDefaultDescription
children*ReactNode-Tab buttons
aria-labelstring-Accessible label for the tab list

Tabs.Tab

Tabs.Tab props
PropTypeDefaultDescription
value*string-Tab identifier
children*ReactNode-Tab label

Tabs.Panel

Tabs.Panel props
PropTypeDefaultDescription
value*string-Associated tab value
children*ReactNode-Panel content

Keyboard Interactions

Accessibility
All keyboard interactions follow WAI-ARIA best practices and work without any additional configuration.
Keyboard shortcuts for Tabs
KeyAction
ArrowLeftMoves to previous tab
ArrowRightMoves to next tab
HomeMoves to first tab
EndMoves to last tab