Option
Option is a segmented control: a track of equal cells where one is selected. Picking a cell changes one value and
nothing else — no panel swaps underneath. It is controlled: you own value and update it from onChange.Forms
When to use
Use when
- Choosing one of two to five short options: side (buy / sell), period (1D / 1W / 1M), a percentage.
- The choice sets a value — a form field, a filter, a chart range.
Avoid when
Usage
const [side, setSide] = useState('buy');
<Option
label="Side"
value={side}
onChange={setSide}
options={[
{ value: 'buy', label: 'Buy' },
{ value: 'sell', label: 'Sell' },
]}
/>;Size and width
size="small" is the chip row under an input; medium (default) stands alone. A cell can be disabled.
fullWidth (default) stretches the track into equal cells; fullWidth={false} sizes it to its content.
<Option size="small" label="Percent of balance" value={pct} onChange={setPct} options={percentOptions} />
<Option fullWidth={false} label="Range" value={range} onChange={setRange} options={rangeOptions} />Icon-only cells
A view switch shows icons alone. Name each cell with ariaLabel — it becomes the radio's accessible name and tooltip.
<Option
fullWidth={false}
label="View"
value={view}
onChange={setView}
options={[
{ value: 'cards', label: <Icon icon={grid} />, ariaLabel: 'Cards' },
{ value: 'list', label: <Icon icon={listView} />, ariaLabel: 'List' },
]}
/>Accessibility
- The track is a
radiogroup; each cell is aradiowitharia-checked. Tablands on the selected cell; arrow keys move the selection, wrapping and skipping disabled cells;HomeandEndjump to the ends.- Name the group with
label, oraria-labelledbywhen a visible label exists. Icon-only cells needariaLabel. - Keyboard focus stays visible in forced-colors mode.
Properties
Name
Type
Default
Description
alignContent"center""start""end""between""around""evenly""stretch"nonePacking of wrapped lines / grid tracks on the block axis.
containmentstringnoneContainment marker for the `cq` channel: emits
`container-type` (+ `container-name` when the string form carries one,
e.g. `'inline-size card'`). Apply on the immediate wrapper of the
adapting component — NEVER on page-level shells.
cqPartial<Record<ContainerSizeTypes, Partial<Omit<Partial<{ area: string; padding: stringnumber; margin: stringnumber; isHidden: boolean; truncate: boolean; lineClamp: number; pageShell: boolean; ... 14 more ...; transform: string; }>, "containment"> & Partial<...> & SizeFactoryProps & Partial<...>>>>noneContainer-relative **layout** styles per `theme.containerSizes` key.
enableBreakpoint"xs""xl""sm""md""lg"noneForces a breakpoint's prop set to apply regardless of viewport (stories/previews).
fullWidthbooleantrueStretch to the container width with equal cells.
ignoreResponsivebooleannoneFully disables the responsive factory (tests / fixed snapshots).
justifyItems"center""start""end""stretch"noneGrid containers: inline alignment of every item in its cell.
labelstringnoneAccessible name of the group (`aria-label` on the `radiogroup`).
Prefer `aria-labelledby` when a visible label exists.
lineClampnumbernoneCaps the text at this many lines and ends the cut with an ellipsis.
The full string stays in the DOM.
onChange *(value: string) => voidnoneFired with the picked value. Not fired when the selected cell is clicked again.
options *OptionItem<string>[]noneCells, in order. Two or more.
pageShellbooleannoneCenters the element and caps the width at `theme.layout.pageMaxWidth`.
The page shell of a classic centered layout.
placeItems"center""start""end""stretch"noneGrid containers: `place-items` shorthand (block + inline).
size"small""medium"'medium'Cell height scale.
transformstringnoneCSS `transform` value (e.g. `translate(-50%, -33px)`). Never leaks
to the DOM as an attribute.
value *stringnoneCurrently selected value. Must match one `options[].value`.
viewportMediasPartial<Record<keyof BreakPoint<any>, Partial<Omit<Partial<{ area: string; padding: stringnumber; margin: stringnumber; isHidden: boolean; truncate: boolean; lineClamp: number; pageShell: boolean; ... 14 more ...; transform: string; }>, "containment"> & Partial<...> & SizeFactoryProps & Partial<...>>>>undef...noneViewport-driven **layout** styles per `theme.breakpoints` key.
The track also accepts the layout props of a Flex.