Tabs

Line tabs for switching between related panels.

StableSource
Three deployments this week, all healthy.

Import

tsx
import { Tabs } from "@merid/react";

Anatomy

tsx
<Tabs.Root>
  <Tabs.List>
    <Tabs.Trigger value="a" />
  </Tabs.List>
  <Tabs.Panel value="a" />
</Tabs.Root>
  • Root holds the selected value and orientation.
  • List is the role="tablist"; give it an aria-label.
  • Trigger is one role="tab" button, linked to its panel by value.
  • Panel is the role="tabpanel". Inactive panels unmount unless forceMount is set.

Examples

Controlled

Showing data for one week.

Vertical

With orientation="vertical", the list stacks and ArrowUp/ArrowDown move between tabs.

Name, avatar and time zone.

API reference

Root

Accepts every <div> attribute except defaultValue and onChange.

PropTypeDefaultDescription
valuestring–Controlled selected tab value.
defaultValuestring""Initially selected tab value when uncontrolled.
onValueChange(value: string) => void–Called when the selected tab changes.
orientation"horizontal" | "vertical""horizontal"Arrow-key axis.
refRef<HTMLDivElement>–Forwarded ref to the root element.

List

Accepts every <div> attribute.

PropTypeDefaultDescription
variant"line""line"Visual style. Only "line" today.
refRef<HTMLDivElement>–Forwarded ref to the tablist.

Trigger

Accepts every <button> attribute except value.

PropTypeDefaultDescription
valueRequiredstring–Value identifying this tab and its panel.
disabledboolean–Disable the tab; it is skipped by arrow keys.
refRef<HTMLButtonElement>–Forwarded ref to the tab button.

Panel

Accepts every <div> attribute.

PropTypeDefaultDescription
valueRequiredstring–Value of the tab that owns this panel.
forceMountbooleanfalseKeep the panel mounted (hidden) while inactive.
refRef<HTMLDivElement>–Forwarded ref to the panel.

Styling

ClassElement
.mrd-tabsRoot
.mrd-tabs__listList
.mrd-tabs__triggerTrigger
.mrd-tabs__panelPanel
AttributeOnValues
data-orientationRoothorizontal, vertical
data-variantListline
data-stateTrigger, Panelactive, inactive
data-disabledTriggerpresent when disabled
aria-selected="true"Triggerthe selected tab (styled with the accent underline)

Accessibility

Follows the WAI-ARIA Tabs pattern with automatic activation: moving focus selects the tab. Only the selected tab is in the tab order; the panel itself is focusable so keyboard users can reach content without interactive elements.

KeyAction
TabMove focus into the tab list (selected tab), then to the panel.
ArrowRightHorizontal: next tab, wrapping. Selects it.
ArrowLeftHorizontal: previous tab, wrapping. Selects it.
ArrowDownVertical: next tab, wrapping. Selects it.
ArrowUpVertical: previous tab, wrapping. Selects it.
HomeFirst tab.
EndLast tab.

Guidelines

Do

Use tabs for peer views of the same object, with short one- or two-word labels.

Avoid

Use tabs for sequential steps — use a Stepper — or for switching a small control mode, which is a SegmentedControl.

Do

Keep the tab row on one line; move rarely used views into a menu.

Avoid

Nest a second row of tabs inside a panel.