SegmentedControl

Switches between a few mutually exclusive views or modes.

  • Native host
  • Liquid Glass on iOS 26
  • In the first release
import { SegmentedControl, segmentedControlPrimitive } from "nitro-ui-sdk/segmented-control";
HeroUI Native
Segment (Pro)
Expo UI
SegmentedButtonPicker (segmented)
  • SegmentedControl example screen, light appearance
    Light
  • SegmentedControl example screen, dark appearance
    Dark
  • SegmentedControl example screen, liquid glass appearance
    Liquid Glass
On this page

Switches between 2 to 4 mutually exclusive views or modes using the native segmented control (UISegmentedControl on iOS, MaterialButtonToggleGroup on Android). Use SegmentedControl for immediate view/filter switching; use RadioGroup for longer labeled options or Tabs when switching full content panels.

Anatomy

<SegmentedControl.Root label="Project view" defaultValue="list" variant="mixed">
  <SegmentedControl.Segment value="list" label="List">
    <SegmentedControl.Icon iosSymbol="list.bullet" androidDrawable="ic_menu_sort_by_size" />
  </SegmentedControl.Segment>
  <SegmentedControl.Segment value="grid" label="Grid">
    <SegmentedControl.Icon iosSymbol="square.grid.2x2" androidDrawable="ic_menu_gallery" />
  </SegmentedControl.Segment>
</SegmentedControl.Root>
Part Description
SegmentedControl.Root Manages single selection, controller attachment, agent registration, optional Liquid Glass shell, and native host.
SegmentedControl.Segment Declares one segment option (value, label, optional icon, disabled).
SegmentedControl.Label Style slot or text override for segment titles.
SegmentedControl.Icon Declares platform icons (iosSymbol, androidDrawable) and icon tint/size style slot.

Usage

import { SegmentedControl } from "nitro-ui-sdk/segmented-control";

<SegmentedControl.Root label="Range" defaultValue="week">
  <SegmentedControl.Segment value="day" label="Day" />
  <SegmentedControl.Segment value="week" label="Week" />
  <SegmentedControl.Segment value="month" label="Month" />
</SegmentedControl.Root>;

Variants and sizes

variant selects "text" (default, titles only), "icon" (symbols), or "mixed" (icons where supplied, titles otherwise). size supports "sm", "md" (default), and "lg", maintaining at least a 44 pt touch height.

<SegmentedControl.Root label="Density" size="sm" defaultValue="a">
  <SegmentedControl.Segment value="a" label="Compact" />
  <SegmentedControl.Segment value="b" label="Standard" />
</SegmentedControl.Root>

States

Pass disabled on SegmentedControl.Root to disable all segments, or disabled on an individual SegmentedControl.Segment to lock a single option with explicit disabled text and icon styling.

<SegmentedControl.Root label="View" defaultValue="list">
  <SegmentedControl.Segment value="list" label="List" />
  <SegmentedControl.Segment value="grid" label="Grid" />
  <SegmentedControl.Segment value="board" label="Board" disabled />
</SegmentedControl.Root>

Controlled

Provide value and onValueChange to control selection. Returning without updating value or calling details.preventDefault() reconciles the native control back to the committed segment.

import { useState } from "react";
import { SegmentedControl } from "nitro-ui-sdk/segmented-control";

const [mode, setMode] = useState("map");

<SegmentedControl.Root label="Mode" value={mode} onValueChange={setMode}>
  <SegmentedControl.Segment value="map" label="Map" />
  <SegmentedControl.Segment value="satellite" label="Satellite" />
</SegmentedControl.Root>;

Liquid Glass

Pass glass when placing SegmentedControl in a floating navigation layer over content or imagery. On iOS 26+ with transparency enabled it renders inside a MaterialView (LiquidGlassView), falling back to an opaque neutral surface (tokens.colors.default with tokens.colors.border) when glass is off or unsupported.

<SegmentedControl.Root label="Overlay mode" glass defaultValue="photo">
  <SegmentedControl.Segment value="photo" label="Photo" />
  <SegmentedControl.Segment value="video" label="Video" />
</SegmentedControl.Root>

Props

SegmentedControl.Root

Prop Type Default Description
label string — Required accessible name for the control.
options readonly SegmentProps[] Derived from Segment children Declarative segment array alternative to children.
value string undefined Controlled selected segment key.
defaultValue string First enabled segment Initial uncontrolled segment key.
onValueChange (value: string, details: ActionDetails) => void undefined Called before the selected segment changes.
variant "text" | "icon" | "mixed" "text" Controls whether segment icons are used.
size "sm" | "md" | "lg" "md" Control height and title font scale.
glass boolean false Wraps the control in a Liquid Glass pill (MaterialView) with opaque fallback.
disabled boolean false Disables the entire control.
styles PartStyles<SegmentedControlPart, SegmentedControlVariant, SegmentedControlSize, SegmentedControlState> undefined Per-part style overrides.
api Controller<SegmentedControlActions> undefined Imperative controller created with segmentedControlPrimitive.createApi().
agentId string undefined Stable agent identity when rendered in recyclable rows.
layout SharedViewProps["layout"] undefined Additional layout props merged onto the outer container.
children ReactNode undefined SegmentedControl.Segment children.

SegmentedControl.Segment

Prop Type Default Description
value string — Unique segment key.
label string — Segment title (also used as icon accessibility label).
icon { iosSymbol: string; androidDrawable: string } undefined Optional segment icon when variant is "icon" or "mixed".
disabled boolean false Disables this individual segment.
part SegmentedControlPart "segment" Overrides the style slot for the selected pill.

Controller API

import { SegmentedControl, segmentedControlPrimitive } from "nitro-ui-sdk/segmented-control";

const api = segmentedControlPrimitive.createApi();
<SegmentedControl.Root label="Range" api={api}>
  <SegmentedControl.Segment value="day" label="Day" />
  <SegmentedControl.Segment value="week" label="Week" />
</SegmentedControl.Root>;
api.current?.select("week");
Action Signature Result
select (key: string, source?: ActionSource) => ChangeStatus Selects key, returning "disabled" or "unavailable" if ineligible.

Styles

Style resolvers receive { tokens, variant, size, state } where state is { disabled: boolean; value: string | undefined; glass: boolean }.

<SegmentedControl.Root
  label="Accent pill"
  defaultValue="a"
  styles={{
    segment: ({ tokens }) => ({ style: { background: tokens.colors.accentSoft } }),
    label: ({ tokens }) => ({ text: { color: tokens.colors.accentSoftForeground } }),
  }}
>
  <SegmentedControl.Segment value="a" label="Alpha" />
  <SegmentedControl.Segment value="b" label="Beta" />
</SegmentedControl.Root>

Accessibility

On iOS, UISegmentedControl uses accessibilityContainerType = .semanticGroup, labels every icon image with its segment title, and applies explicit .disabled title attributes. On Android, MaterialButtonToggleGroup carries contentDescription and explicit enabled/disabled tint state lists. Touch selection plays selectionChanged() haptics; agent and API actions never vibrate.

Agent API

Action Arguments Notes
select string (segment key) Selects an enabled segment from the exported options list and settles controlled updates.

Platform notes

iOS Android
Implementation UISegmentedControl with Dynamic Type font scaling, SF Symbol icons, and optional MaterialView Liquid Glass pill. MaterialButtonToggleGroup with single-selection enforcement and opaque MaterialView fallback.
Verification Unit, type, iOS harness, and simulator screenshot verified. Written to compile; not built locally (no Android NDK on this machine).