Skip to content

SegmentedControl

Picks one of a few mutually exclusive options. It’s a radiogroup—you move through it with the arrow keys (selection follows focus), and it exposes its value. A good fit for switching views or filters where a Select would be overkill.

Forms · TaishoDS Core, in plain HTML.

Examples

One working example per case. Each example is the HTML of its preview—copy it as is, and with Core’s CSS and JS loaded, it looks and works the same.

Period selector

html

When to use

  • Switching between 2–4 options that should always be visible (views, filters).
  • The change shows up instantly, and opening a panel isn’t worth it.
  • You want the options and the selected one to read at a glance.

When not to use

  • There are many options, or they don’t fit → select.
  • The options need a description or stack vertically → radio.
  • It’s navigation between content sections, not a value → tabs.

Do

  • Keep labels short and similar in length, so they fit the same width without wrapping.
  • A handful of options at most. If you’re unsure, it’s already a select.

Don’t

  • Don’t use it to move between pages or large views → tabs.
  • Don’t cram in six options. It gets tight and loses legibility.

TaishoDS Core

Needs Core’s JS, which hooks in through data-ts-* attributes.

Core owns the selection and keyboard navigation between segments.

Core hooks into it through these attributes. They go in the markup, and there’s nothing to initialize.

  • data-ts-segmented
  • data-ts-segmented-option
  • data-ts-value

What it does: Selects the segment, keeps aria-checked in sync, and moves between options with the arrow keys.

From the CDN, without a build, load taisho.segmented-control.css along with taisho.base.css. Also load:

  • taisho.button.css
  • taisho.spinner.css

For how Core works in general, see Behavior.

Accessibility

Implements the Radio Group pattern from the WAI-ARIA APG.

  • radiogroup role with radio children—the right semantics for choosing one value. Each radio takes its name from the segment’s text.
  • Roving tabindex. Only the active segment is in the Tab order. The arrow keys move focus, and the selection follows (Home/End go to the first/last).
  • Disabled options are skipped during keyboard navigation.
  • Provide an accessible name with aria-label or aria-labelledby—the control doesn’t render its own label.

Keyboard

On top of what the browser already does (Tab moves focus, Enter activates a button).

Key What it does
→←Next and previous segment (wrapping around). On an RTL page they swap: ← moves forward and → moves back.
↓↑Next and previous segment, like a native radio group. They don’t depend on the writing direction.
Home/EndFirst and last enabled segment.

Verification

What was actually tested. Anything that wasn’t tested says so—we’d rather say “not verified” than claim too much.

  • axe WCAG 2.2 A + AA in a real browser, in light and dark mode, before every release.
  • keyboard Key map documented above, checked against the component.
  • screen reader Not verified with a screen reader. Test it in your own combination of components, not just here, where each one appears alone and on its happy path.