Skip to content
Vertical Jump Designs-uiFront-End Studio
Get Pro

v3.9 is out.

Forms

SegmentedControl

Free2.7 KB gzipped

Single-choice segmented control. See SegmentedControlProps; segments via options or SegmentedControl.Item.

Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · Keys: Tab, Arrow keys · Full report

Import

tsx
import { SegmentedControl } from "@vjdesigns/vjdesigns-ui";

Importing only SegmentedControl adds about 2.7 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.

Examples

Basic

A single choice from a few options, shown side by side. It's a radio group, so arrow keys move the selection.

Calendar view
tsx
import { useState } from "react";
import { SegmentedControl } from "@vjdesigns/vjdesigns-ui";

export function Basic() {
  const [view, setView] = useState("week");
  return (
    <SegmentedControl
      label="Calendar view"
      value={view}
      onValueChange={setView}
      options={[
        { value: "day", label: "Day" },
        { value: "week", label: "Week" },
        { value: "month", label: "Month" },
      ]}
    />
  );
}

With icons

Compose SegmentedControl.Items to add icons. tone="primary" colors the selected segment.

Layout
tsx
import {
  CalendarIcon,
  ClockIcon,
  MenuIcon,
  SegmentedControl,
  Stack,
} from "@vjdesigns/vjdesigns-ui";

export function WithIcons() {
  return (
    <Stack gap={4} align="center">
      <SegmentedControl label="Layout" defaultValue="list" tone="primary" size="sm">
        <SegmentedControl.Item value="list" icon={<MenuIcon />}>
          List
        </SegmentedControl.Item>
        <SegmentedControl.Item value="calendar" icon={<CalendarIcon />}>
          Calendar
        </SegmentedControl.Item>
        <SegmentedControl.Item value="timeline" icon={<ClockIcon />}>
          Timeline
        </SegmentedControl.Item>
      </SegmentedControl>
    </Stack>
  );
}

Accessibility

Each segment is a native radio, so the control is one Tab stop and the arrow keys change the choice. label names the group; an icon-only segment needs an aria-label of its own.

View
tsx
import {
  CalendarIcon,
  ClockIcon,
  MenuIcon,
  SegmentedControl,
} from "@vjdesigns/vjdesigns-ui";

export function Accessibility() {
  return (
    <SegmentedControl label="View" defaultValue="list">
      <SegmentedControl.Item value="list" icon={<MenuIcon />} aria-label="List view" />
      <SegmentedControl.Item value="calendar" icon={<CalendarIcon />} aria-label="Calendar view" />
      <SegmentedControl.Item value="timeline" icon={<ClockIcon />} aria-label="Timeline view" />
    </SegmentedControl>
  );
}

Translated

In Arabic the segments run right to left, and the arrow keys follow the reading direction. The segment labels are your own text.

الفترة
tsx
import { SegmentedControl, LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";

export function Translated() {
  return (
    <LocaleProvider locale="ar" messages={ar}>
      <SegmentedControl
        label="الفترة"
        defaultValue="week"
        options={[
          { value: "day", label: "يوم" },
          { value: "week", label: "أسبوع" },
          { value: "month", label: "شهر" },
        ]}
      />
    </LocaleProvider>
  );
}

API reference

SegmentedControl

SegmentedControl props
PropTypeDefault
options

Segments as data. Use this or SegmentedControl.Item children.

SegmentedControlOption[]—
children

SegmentedControl.Item segments, as direct children. Ignored when options is set.

ReactNode—
value

Selected value (controlled). Use with onValueChange.

string—
defaultValue

Initially selected value (uncontrolled). Leave unset for no initial selection (no thumb).

string—
onValueChange

Called with the newly selected segment's value.

(value: string) => void—
name

Shared name for the native radios (used in form submission). Generated with useId when omitted.

string—
size

Height and text size. Falls back to a surrounding Field's size.

"sm""md""lg""md"
tone

Thumb color: raised neutral surface, or solid primary with on-primary text.

"neutral""primary""neutral"
radius

Corner rounding of the track; the thumb and segments follow it.

"none""xs""sm""md""lg""xl""2xl""pill""pill"
fullWidth

Stretch to the container's width with equal-width segments.

boolean—
orientation

Lay segments out in a row or a column. Arrow keys work in both directions either way.

"horizontal""vertical""horizontal"
disabled

Disables every segment. Falls back to a surrounding Field's state.

boolean—
invalid

Invalid styling and aria-invalid. Falls back to a surrounding Field's state.

boolean—
required

A selection is required: native required on the radios, aria-required on the group.

boolean—
label

Visible group label, shown above the track when the control stands alone. Ignored inside a Field/Fieldset, whose label or legend already names the group. Without a label, pass aria-label or aria-labelledby.

ReactNode—

Also accepts native <div> attributes, plus className, style and ref.

SegmentedControl.Item

One segment (a native radio).

SegmentedControl.Item props
PropTypeDefault
valueRequired

Value submitted with the form and reported by onValueChange.

string—
icon

Decorative icon before the label (e.g. <Icon name="calendar" />).

ReactNode—
disabled

Disables this segment (the control's disabled also applies). Arrow keys skip it.

boolean—
className

Class for the segment (label) element. The ref and other native props go to the input.

string—
children

Visible segment label.

NonNullable<ReactNode>—
aria-label

Overrides the accessible name (rarely needed).

string—

Also accepts standard HTML attributes, plus className, style and ref.

See what changed in each version in the Changelog.

Accessibility report

SegmentedControl targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.

axe-core audit (live)

Running accessibility audit

Checking the examples above…

Lighthouse audit

Light mode

Score 100

36 passed · 0 failed · 29 not applicable · 10 to check by hand

Dark mode

Score 100

36 passed · 0 failed · 29 not applicable · 10 to check by hand

Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.

Built-in behavior

Keyboard

Keyboard
KeyAction
TabMoves into the control, on the selected option.
Arrow keysMoves to and selects the next or previous option, wrapping.

Roles and states

Roles and states
ElementRoleStates and properties
Controlradiogrouparia-labelledby
Option (<input type="radio">)radioChecked state is native

Manual checks

Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.

Manual accessibility checks
CheckWhat to testWCAG 2.2
KeyboardEvery action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck.2.1.1 (A), 2.1.2 (A)
FocusFocus moves in a logical order, is always visible, and isn't hidden behind sticky headers.2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA)
Screen readersNames, roles and states are announced correctly, and status changes are announced without moving focus.1.3.1 (A), 4.1.2 (A), 4.1.3 (AA)
ColorMeaning never depends on color alone; your own colors meet contrast in both modes.1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA)
Zoom and reflowAt 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed.1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA)
Pointer targetsClick and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap.2.5.8 (AA), 2.5.5 (AAA)
MotionAnimations respect the reduced-motion setting.2.3.3 (AAA)