Meridianby Commenda
Components

SegmentedControl

Switch between two to four views in place.

Switches between two to four views or modes in place. The selected segment lifts out of a soft tray, at the same heights as Button. On the site it toggles pricing periods, map and list views, and product tabs inside a section.

MonthlyAnnually
USUKIndia
Sales taxVATGSTPayroll

Usage

Example.tsx
import { SegmentedControl } from "@commenda/meridian/ui/segmented-control";

<SegmentedControl
  label="Billing period"
  value={period}
  onValueChange={setPeriod}
  options={[
    { value: "monthly", label: "Monthly" },
    { value: "annually", label: "Annually" },
  ]}
/>;

Two to four options

Equal-weight choices that change what the section shows, with one always selected.

MonthlyAnnually
USUKIndia
Sales taxVATGSTPayroll

With icons

A 16 icon before the label, or icons alone for a view toggle. Icon-only segments need a Tooltip.

MapList

Sizes

sm 28 and md 32, the same heights as Button so they line up in a row.

USUKIndia
sm · 28
USUKIndia
md · 32

Segment states

Hover fills the segment soft-pearl 300. Focus is the blue ring with a white gap. Disabled dims the label.

USUKIndia
one segment disabled
USUKIndia
whole control disabled

Hover and Tab through the controls above to see hover and focus.

Anatomy

PartValue
Traysoft-pearl 200, 0.5 hairline soft-pearl 300, radius 8, 2 padding and 2 between segments
Segmentradius 6 so the corners nest, padding 8 (sm) or 12 (md), Label/13 Strong, optional 16 icon 6 before it
Selectedwhite, hairline, Elevation/control
Heightsm 28 · md 32 (control/md)

API reference

PropTypeDescription
labelRequiredstringFrom Pathfinder.
optionsRequiredSegmentedControlOption[]From Pathfinder.
styleCSSProperties | ((state: RadioGroupState) => CSSProperties | undefined)Style applied to the element, or a function that returns a style object based on the component's state.
formstringIdentifies the form that owns the radio inputs. Useful when the radio group is rendered outside the form.
disabledbooleanWhether the component should ignore user interaction.
namestringIdentifies the field when a form is submitted.
readOnlybooleanWhether the user should be unable to select a different radio button in the group.
requiredbooleanWhether the user must choose a value before submitting a form.
inputRef((instance: HTMLInputElement | null) => void | (() => VoidOrUndefinedOnly) | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | RefObject<HTMLInputElement | null>A ref to access the hidden input element.
size"md" | "sm"From Pathfinder.
classNamestringFrom Pathfinder.
disabledReasonstringFrom Pathfinder.
valueConditionalstringFrom Pathfinder.
onValueChangeConditional(value: string) => voidFrom Pathfinder.
defaultValueConditionalstringFrom Pathfinder.

Best practices

  • Use a SegmentedControl for two to four short, equal options that switch the view in place. More options, or sections with their own content, use Tabs.
  • One segment is always selected. There is no empty state. Changing it updates the view at once, with no Apply.
  • Keep labels to one or two words, and similar in length. Icon-only segments need a Tooltip and an aria-label.
  • Never use a segment for an action. It never submits a form or opens a demo booking. For on or off, use a Switch.
  • Source: Pathfinder SegmentedControl. Meridian keeps it as is.

On this page