Theme studio

Design a theme, preview it live, then export it. Saved in this browser.

Quick picks #10b981
Generated scale
50100200300400500600700800900
Some text is below AA

SegmentedControl

  • Needs review
  • WCAG 2.2 evidence
  • RTL

A single choice between two to four closely related options, such as a chart range (3M / 6M / 12M) or a calendar view (Day / Week / Month). Built on React Aria ToggleButtonGroup with single selection: a named radiogroup of Segment radios. Arrow keys move focus between segments (mirrored in right-to-left locales), Enter and Space select, Tab leaves the control (WCAG 2.1.1, 4.1.2). Controlled with selectedKeys and onSelectionChange, uncontrolled with defaultSelectedKeys. Consumer duties: a name for the control, short translated labels, and a default selection.

import { SegmentedControl } from "@nexera-ui/react";
Loading example…
5
examples
11
props
3
live controls
1
platform
5
WCAG criteria
10
blocks use it

Try every prop. Copy the code.

Change the props and the code updates. Check light and dark, LTR and RTL, and phone width.

Loading…
children
disallowEmptySelection
isDisabled
Generated code
import { SegmentedControl } from "@nexera-ui/react";

<SegmentedControl />

Examples 4

The same examples as Storybook, rendered live. Open Code to copy one.

Options

Figma Options = 2, 3 and 4, derived from the number of Segment children.

Loading example…

Chart range

The chart range control is this component with three segments, named by the chart title through aria-labelledby.

Loading example…

With icons

Segments with icons, and icon-only segments named by aria-label.

Loading example…

Long labels

Labels wrap instead of truncating; the other segments stretch to the same height.

Loading example…

Props 11

Press "Try it" on a card to load that prop into the playground.

11 props shown

children*Nexera
ReactNode

The options: two to four Segment elements. Use a Select for more options and Tabs for sections of a page.

Default –
disallowEmptySelectionNexera
boolean

Keeps one segment selected: pressing the selected segment again does nothing. Set to false to let users clear the selection.

Default true
classNameNexera
string

Extra classes, merged last so they win over the defaults.

Default –
styleNexera
CSSProperties

Inline style.

Default –
aria-labelNexera
string

Accessible name of the choice ("Range", "Period"). Translate it. Accessible name; aria-labelledby wins when both are set.

Default –
aria-labelledbyNexera
string

Id(s) of element(s) that name the control; wins over aria-label. Id(s) of the visible element(s) that name the control, for example the chart title.

Default –
selectedKeysReact Aria
Iterable<Key>

The currently selected keys in the collection (controlled).

Default –
defaultSelectedKeysReact Aria
Iterable<Key>

The initial selected keys in the collection (uncontrolled).

Default –
onSelectionChangeReact Aria
(keys: Set<Key>) => void

Handler that is called when the selection changes.

Default –
isDisabledReact Aria
boolean

Whether all items are disabled.

Default –
aria-describedbyReact Aria
string

Identifies the element (or elements) that describes the object.

Default –

* Required. React Aria props shown are the ones most apps use; the component accepts the rest of its React Aria props too.

Accessible by default.

Built on React Aria, and covered by the WCAG 2.2 evidence generated on every build.

WCAG 2.2 evidence

3 direct · 2 supporting
  • 1.3.1Info and RelationshipsLevel A · tested directly
  • 1.4.10ReflowLevel AA · supporting test
  • 1.4.12Text SpacingLevel AA · supporting test
  • 2.1.1KeyboardLevel A · tested directly
  • 4.1.2Name, Role, ValueLevel A · tested directly

Fits any width.

Nexera components respond to the space they are given. Drag the corner of the frame, or pick a width.

0 px · drag the corner

Styling hooks

Pass className to add Tailwind classes (merged last). State is exposed as data attributes, so you can style it with variants like data-pressed:.

Usage
<SegmentedControl className="shadow-sm" />

Used in blocks

Related components