- Add the registry
- Add segmented-control
Usage
Once a segment is chosen, one always is. Give the control an aria-label, or a FieldLabel in a
Field.
Composition
Examples
Controlled
Pass value and onValueChange to control the selection.
Showing cost
Icon only
Give icon-only items an aria-label. size="sm" makes a smaller control.
Disabled options
Full width
Give the control a width and the segments stretch to fill it.
In a form
Give a Field or the control a name, and the chosen value submits under it, or pass form with
a form's id when the control sits outside it. Leave out defaultValue to make people choose, and
with required the form won't submit until they do, which fails as valueMissing. A form reset
brings back defaultValue. In a Field, a FieldLabel names the control, and it reads out the
field's FieldDescription and FieldError and turns invalid or disabled with the field.
Props
Unlike Toggle Group, its value is a single string rather than an array.
The tables leave out className, style and render. Parts built on Base UI take them as its styling and composition guides describe.