Skip to content

Segmented Control

A softly raised selection glides between compact, tactile options.

LIVE PREVIEWInteract with the component
Just React. No extra dependencies.

Copy the component and its CSS module into your project.

CSS Modules

Usage

Matches your current playground settings.

jsx
import SegmentedControl from "./SegmentedControl";
export default function Example() {
return (
<SegmentedControl
items={[
{
"value": "day",
"label": "Day"
},
{
"value": "week",
"label": "Week"
},
{
"value": "month",
"label": "Month"
}
]}
defaultValue={"week"}
label={"Calendar view"}
accentColor={"#e4d7ed"}
background={"#28202f"}
/>
);
}

Using Segmented Control

Use a small collection of mutually exclusive choices through items. Give the group a label that explains what is being selected.

Pair value with onValueChange for controlled selection, or use defaultValue for local state. Keep the option labels short enough to fit side by side.

Props

NameTypeRequiredDefaultDescription
itemsobject[]No[]Array of { value, label, icon?, disabled? }. Use unique string values. Icons accept React nodes.
valuestringNoundefinedOptional controlled selected value.
defaultValuestringNoundefinedInitial uncontrolled selection; otherwise the first enabled item is selected.
onValueChangefunctionNoundefinedCalled with the selected value.
labelstringNo"Choose an option"Accessible label for the radio group.
accentColorstringNo"#e4d7ed"Selected surface colour.
backgroundstringNo"#211b27"Track background colour.
classNamestringNo""Additional CSS classes merged with the component styles.
styleCSSPropertiesNoundefinedInline styles for sizing, typography, and visual overrides.

Related components

A recessed password field pairs a reveal control with an optional strength indicator.

Editable tags collect inside a softly framed input with individual remove controls.

A recessed search field expands into a polished capsule as you type.

Faceted stars lift into selection with a small marker beneath the chosen rating.