Skip to content
Alea0.1

Actions

SegmentedControl

One choice among two to five options, shown as a row of pills. ToggleButton is the single on/off version.

Ant Design: Segmented

import { SegmentedControl, ToggleButton } from '@alea/ui';

Examples

Segmented control

A short, exclusive choice. The first option is selected unless you set one.

Showing: week

Small

For toolbars and dense panels.

ToggleButton

One button that stays pressed, like Bold. aria-pressed tells screen readers.

Props

SegmentedControl props

One choice among a few, as a row of pills (Ant's Segmented).

PropTypeDefaultDescription
itemsrequired{ id: Key; label: ReactNode; isDisabled?: boolean | undefined; }[]-The options: id and label.
aria-labelstring-Label for screen readers.
defaultValueKey-Selected id to start with.
onChange((value: Key) => void)-Called with the id of the option picked.
size"sm" | "md"'md'sm (28 px) or md (34 px, default).
valueKey-Selected id (controlled).

ToggleButton props

A button that stays pressed (bold, mute, pin).

PropTypeDefaultDescription
size"sm" | "md" | "lg"'md'sm (32 px) or md (40 px, default).

Accessibility

  • The group is a radio group: one option is always selected and announced as such.
  • ToggleButton is a button with aria-pressed.

Keyboard

KeyDoes
TabMoves into the group (to the selected option)
Arrow keysMove between options
Enter or SpaceSelects the focused option

Do and don't

Do

  • Use for views of the same content (Day, Week, Month).
  • Keep labels short, one or two words.

Don't

  • Don't use for more than five options: use Select.
  • Don't use for actions: use Buttons.

In Figma

Segmented control with 2 to 5 items and a Selected property per item.

Tested with axe, keyboard and screen reader roles