Skip to content
Browse docs and components

Segmented Control

segmented-control

A row of mutually exclusive options whose selected pill moves between them on a spring. It behaves as a radio group, with one tab stop and arrow keys that move the selection, and reduced motion turns the spring into a cut.

Responsive

Install

$npxshadcnadd@forme/segmented-control

Adds the component, its registry dependencies, and the token stylesheet you import once.

Usage

import { SegmentedControl } from "@/components/forme/segmented-control/segmented-control";

<SegmentedControl
  label="Range"
  defaultValue="week"
  options={[
    { value: "day", label: "Day" },
    { value: "week", label: "Week" },
    { value: "month", label: "Month" },
  ]}
/>

When to use

Reach for it

  • Two to five mutually exclusive views of the same content: Day, Week, Month or List, Board.

Use something else

  • Options that lead to different pages or panels with their own content — use Tabs.
  • More than five options, or long labels; use a Select.

API reference

Read from the source, so it is the API of the file you install. A prop marked * is required.

SegmentedControl

A small set of mutually exclusive views — Day / Week / Month, List / Board.

PropTypeDefaultDescription
options*readonly SegmentedOption[]—
label*string—Accessible name for the group.
valuestring—
defaultValuestring—
onValueChange(value: string) => void—
size"sm" | "md""md"
classNamestring—

Accessibility

  • It is a radio group: one tab stop, and the arrow keys move and select.
  • An option whose label is only an icon needs its own aria-label.

Motion

  • The selected pill travels between options on a shared layout spring, which says “the same control, a new value”.
  • Reduced motion turns the spring into a cut.