Select
A dropdown select input with single selection and data-driven options.
A dropdown select input. Wraps Base UI Select with StyleX styling. Supports single selection and data-driven option rendering.
Usage
API Reference
| Prop | Type | Default | Description |
|---|---|---|---|
options | SelectOption[] | — | Data-driven option list |
placeholder | string | "Select…" | Placeholder text when no value selected |
position | 'align-item' | 'below' | 'align-item' | Popup placement: align selected item with trigger, or drop below |
size | 'sm' | 'md' | 'lg' | 'md' | Trigger size. Matches the Input height of the same size |
value | string | — | Controlled value |
defaultValue | string | — | Uncontrolled default value |
onValueChange | (value: string) => void | — | Called when selection changes |
disabled | boolean | false | Disables the trigger |
icons | { trigger?: ReactNode; selected?: ReactNode } | — | Replaces the built-in icons. See the Icons guide |
sx | StyleXStyles | — | StyleX override for the trigger. The trigger is width: 100% by default |
SelectItem
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | — | Option value |
disabled | boolean | — | Disable this option |
icons | { selected?: ReactNode } | — | Replaces the built-in icons. See the Icons guide |
sx | StyleXStyles | — | StyleX style override |
children | ReactNode | — | Option label content |
SelectGroup
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | — | Group label |
children | ReactNode | — | Group items |
SelectSeparator
Visual divider between options. No additional props.
Variants
Default (uncontrolled)
<Select defaultValue="apple" options={options} />Controlled
const [value, setValue] = useState('');
<Select value={value} onValueChange={setValue} options={options} />;With groups
Position
Control where the popup opens relative to the trigger. align-item (the default) aligns the selected item over the trigger; below drops the list beneath it.
Sizes
Set size to sm, md (the default), or lg. Each size has the same height as the Input, DatePicker, and Button of the same size, in any font, so they line up in a row.
Width
The trigger fills its container (width: 100%), the same as Input. This fits a form, where the Select sits in a Field. In a toolbar row, it takes the full row and pushes the other controls to the next line. Give it a width with sx:
To size the trigger to its content, use sx with width: 'auto'.
Performance
For lists exceeding 100 items, render options virtualized rather than as static DOM nodes. Mounting hundreds of <li> elements at once costs initial paint time and memory.
Virtualization with @tanstack/react-virtual
import { useVirtualizer } from '@tanstack/react-virtual';
import { Select } from '@matix/components/select';
import { Select as BaseSelect } from '@base-ui/react/select';
import * as stylex from '@stylexjs/stylex';
const ITEM_HEIGHT = 36; // px — must match the CSS height of SelectItem
const virtual = stylex.create({
scroller: { height: '320px', overflowY: 'auto' },
spacer: { position: 'relative' },
item: { position: 'absolute', left: 0, right: 0, height: ITEM_HEIGHT },
});
function VirtualizedSelect({ options }: { options: SelectOption[] }) {
const parentRef = useRef<HTMLDivElement>(null);
const virtualizer = useVirtualizer({
count: options.length,
getScrollElement: () => parentRef.current,
estimateSize: () => ITEM_HEIGHT,
overscan: 5,
});
return (
<BaseSelect.Root>
<BaseSelect.Trigger>...</BaseSelect.Trigger>
<BaseSelect.Portal>
<BaseSelect.Positioner>
<BaseSelect.Popup>
{/* Fixed-height scroll container */}
<div ref={parentRef} {...stylex.props(virtual.scroller)}>
{/* Spacer div that represents total list height */}
<div {...stylex.props(virtual.spacer)} style={{ height: virtualizer.getTotalSize() }}>
{virtualizer.getVirtualItems().map((virtualRow) => {
const opt = options[virtualRow.index];
return (
<BaseSelect.Item
key={opt.value}
value={opt.value}
{...stylex.props(virtual.item)}
style={{ top: virtualRow.start }}
>
<BaseSelect.ItemText>{opt.label}</BaseSelect.ItemText>
</BaseSelect.Item>
);
})}
</div>
</div>
</BaseSelect.Popup>
</BaseSelect.Positioner>
</BaseSelect.Portal>
</BaseSelect.Root>
);
}Rule: Use virtualization for any list with more than 100 items. Below that threshold, the standard options prop renders all items eagerly — the DOM overhead is negligible and avoids the complexity of virtual scroll.Accessibility
- Built on Base UI
Select— full WAI-ARIAcombobox/listboxpattern - Keyboard:
Enter/Spaceto open, arrow keys to navigate,Enterto select,Escapeto close - All options receive
role="option"andaria-selected - Selected option gets a visible check indicator
Theming
Use the sx prop on <Select> to override trigger styles, or build your own trigger using the Base UI primitives directly.