Components

Tabs

A set of layered panels where only one is visible at a time.

Accessible, unstyled components for modern web applications.

Usage

import { Tabs } from "monochrome/react"

<Tabs.Root defaultValue="overview">
  <Tabs.List>
    <Tabs.Tab value="overview">Overview</Tabs.Tab>
    <Tabs.Tab value="features">Features</Tabs.Tab>
  </Tabs.List>
  <Tabs.Panel value="overview">Overview content...</Tabs.Panel>
  <Tabs.Panel value="features">Features content...</Tabs.Panel>
</Tabs.Root>

Examples

Default Tab

Specify which tab is selected initially.

This tab is selected by default because defaultValue="second".
<Tabs.Root defaultValue="second">
  <Tabs.List>
    <Tabs.Tab value="first">First</Tabs.Tab>
    <Tabs.Tab value="second">Second (Default)</Tabs.Tab>
  </Tabs.List>
  <Tabs.Panel value="first">First tab content</Tabs.Panel>
  <Tabs.Panel value="second">This tab is selected by default</Tabs.Panel>
</Tabs.Root>

Vertical Orientation

Use vertical layout for side navigation.

Manage your account settings and preferences.
<Tabs.Root defaultValue="account" orientation="vertical">
  <Tabs.List>
    <Tabs.Tab value="account">Account</Tabs.Tab>
    <Tabs.Tab value="security">Security</Tabs.Tab>
  </Tabs.List>
  <Tabs.Panel value="account">Account settings...</Tabs.Panel>
  <Tabs.Panel value="security">Security options...</Tabs.Panel>
</Tabs.Root>

Disabled Tabs

Disabled tabs cannot be selected and are skipped during keyboard navigation.

Update your name, email, and profile picture.
<Tabs.Root defaultValue="profile">
  <Tabs.List>
    <Tabs.Tab value="profile">Profile</Tabs.Tab>
    <Tabs.Tab value="billing" disabled>Billing (Locked)</Tabs.Tab>
    <Tabs.Tab value="notifications">Notifications</Tabs.Tab>
  </Tabs.List>
  <Tabs.Panel value="profile">Update your profile...</Tabs.Panel>
  <Tabs.Panel value="billing">Billing settings...</Tabs.Panel>
  <Tabs.Panel value="notifications">Notification preferences...</Tabs.Panel>
</Tabs.Root>

Non-Focusable Panels

By default, panels are focusable so keyboard users always have somewhere to land after selecting a tab. When panels contain meaningful focusable elements like buttons or links, this can be turned off by setting focusable to false.

Press Tab from the tab list. The panel receives focus first, then the button.
<Tabs.Root defaultValue="focusable">
  <Tabs.List>
    <Tabs.Tab value="focusable">Focusable</Tabs.Tab>
    <Tabs.Tab value="non-focusable">Non-Focusable</Tabs.Tab>
  </Tabs.List>
  <Tabs.Panel value="focusable">
    <button>Save</button>
    <button>Delete</button>
  </Tabs.Panel>
  <Tabs.Panel value="non-focusable" focusable={false}>
    <button>Save</button>
    <button>Delete</button>
  </Tabs.Panel>
</Tabs.Root>

Accessibility

Follows the WAI-ARIA Tabs Pattern.

Keyboard

Horizontal

KeyAction
Arrow RightMove focus to the next tab
Arrow LeftMove focus to the previous tab
HomeMove focus to the first tab
EndMove focus to the last tab

Vertical

KeyAction
Arrow DownMove focus to the next tab
Arrow UpMove focus to the previous tab
HomeMove focus to the first tab
EndMove focus to the last tab

Disabled tabs are skipped during keyboard navigation. Hidden panels use hidden="until-found" so content remains searchable via browser find-in-page (Ctrl+F).

API Reference

HTML

ElementAttributesDescription
Containerid="mcr:tabs:*"Root ID (required)
data-orientation"horizontal" or "vertical"
Tablistrole="tablist", aria-orientationContainer for tab buttons
Tabrole="tab"Tab button
id="mct:tabs:*"Tab ID (required)
aria-selected"true" or "false"
aria-controlsPanel element ID
tabindex0 for selected, -1 for others
aria-disabled="true"For disabled tabs
Panelrole="tabpanel"Tab content panel
id="mcc:tabs:*"Panel ID (required)
aria-labelledbyTab trigger ID
aria-hidden"true" or "false"
hidden="until-found"Set on hidden panels, removed when visible
tabindex0 for visible, -1 for hidden. Omit if the panel contains focusable content.

React

All components accept className for styling.

Tabs.Root

PropTypeDefaultDescription
defaultValuestringFirst tabInitially selected tab value
orientation"horizontal" | "vertical""horizontal"Layout direction

Tabs.List

Container for the tab triggers.

Tabs.Tab

PropTypeDefaultDescription
valuestringRequiredLinks this trigger to a panel
disabledbooleanfalseWhether the tab is disabled (cannot be selected)

Tabs.Panel

PropTypeDefaultDescription
valuestringRequiredLinks this panel to a trigger
focusablebooleantrueSet to false if the panel contains focusable content

Frequently Asked Questions