ValyroUI Русская версия

Segmented Control

Mode switcher. Free, MIT · Navigation and layout › Switching

Installation

npx valyro-cli@latest add segmented-control
npx shadcn@latest add https://valyro.xyz/r/segmented-control.json
npm install valyro-ui

import 'valyro-ui/styles.css';
import { SegmentedControl } from 'valyro-ui';

Props

PropTypeDefault
optionsSegmentedControlOption[]Segments in order; each shows a label, an icon, or both. Or compose them as children: SegmentedControl.Item.
childrenReactNodeThe compound form instead of options: SegmentedControl.Item elements.
valuestringControlled value; use with onValueChange.
defaultValuestringInitial value when uncontrolled.
onValueChange(value: string) => voidCalled with the new value when it changes.
size'sm' | 'md' | 'lg''md'Control height and text size.
fullWidthbooleanfalseStretch to the container width with equal segments (a label wider than its share keeps its width). Either way, segments that don't fit scroll sideways with faded edges instead of truncating.
invalidbooleanfalseError state, e.g. from a FormField: aria-invalid on the group (an explicit aria-invalid wins).
disabledbooleanfalseDisables every segment, like RadioGroup's disabled.
animation'default' | 'spring''default'spring: the thumb springs to the chosen segment with a slight overshoot. default: the theme's curve.

Compound parts

SegmentedControl.Item (SegmentedControlItem)

Related components

Previous: Tabs · Next: Pagination · All Navigation and layout