SegmentedControl

A pill-shaped single-select toggle for switching between a few views, ranges or modes. It behaves as a radio group: one tab stop, arrow keys to move.

StableSource

Import

tsx
import { SegmentedControl, type SegmentedControlOption } from "@merid/react";

Examples

Controlled

Uncontrolled, the control starts on defaultValue or the first enabled option. For controlled use pass value and onValueChange.

value: month

Icon segments

When a segment's label is an icon, give the option an ariaLabel.

Disabled options, disabled control, full width

API reference

SegmentedControl

The ref and other div attributes go to the role="radiogroup" container.

PropTypeDefaultDescription
optionsRequiredSegmentedControlOption[]–The segments.
valuestring–Selected value (controlled).
defaultValuestring–Initially selected value (uncontrolled). Defaults to the first enabled option.
onValueChange(value: string) => void–Called with the new value when the selection changes.
fullWidthbooleanfalseStretches segments to fill the container.
disabledbooleanfalseDisables the whole control.

SegmentedControlOption

PropTypeDefaultDescription
valueRequiredstring–Value reported on selection.
labelRequiredReactNode–Visible content of the segment.
ariaLabelstring–Accessible name when label is not text (e.g. an icon).
disabledboolean–Makes the segment unselectable and skipped by arrow keys.

Styling

HookValues
.mrd-segmentedPill track; data-full-width when stretched
.mrd-segmented__itemEach segment <button role="radio">
data-stateon · off on each item

On a tray section or tray card the track switches to --mrd-tray-2 automatically. There are no component variables.

Accessibility

  • The container is role="radiogroup", each segment role="radio" with aria-checked. Name the group with aria-label or aria-labelledby.
  • Only the selected segment is in the tab order. Arrow keys move and select at once (APG radio group), skipping disabled segments and wrapping at the ends.
KeyAction
TabMoves focus to the selected segment.
→↓Selects the next enabled segment.
←↑Selects the previous enabled segment.
HomeSelects the first enabled segment.
EndSelects the last enabled segment.

Guidelines

Do

Use two to five short, parallel labels that switch a view in place: Day / Week / Month.

Avoid

Use it for navigation between pages, or for panels with their own content — that is Tabs.

  • Tabs — switch between content panels.
  • Radio — single choice with longer labels or descriptions.
  • Switch — a single on/off setting.