NativeSelect

Not the recommended select: use Select - and <Select native> when you want the platform's own picker, which renders this component for you with the same MenuItem children as every other select.

Demos

For usage examples, visit the component demo page: NativeSelect

Import

import { NativeSelect } from '@soroush.tech/design-system/NativeSelect'

Props

PropTypeDefaultDescription
optionsArray<{ label: string; value: string | number }>-The options to populate the select with. Required.
valuestring | number-Controlled value - matches an option's value.
defaultValuestring | number-Uncontrolled initial value.
onChange(value: string | number) => void-Fired with the selected option's original value - numeric options round-trip as numbers.
placeholderstring-Empty-state label rendered as a disabled first option, shown while nothing is selected.
variant'default' | 'outlined' | 'text' | 'underline''default'Visual style - mirrors TextInput's variants.
colorkeyof Theme['palette']'primary'Focus/active border color - resolves to theme.palette[color]. Inherited from FormControl/Form.
bgkeyof Theme['background']'terminal'Background color - resolves against theme.background.
textColorkeyof Theme['text']color's mainText color of the selected value. Inherited from FormControl/Form.
sizekeyof Theme['sizes']'md'Controls padding and font size. Inherited from FormControl/Form.
disabledbooleanfalseDisables the select. Inherited from FormControl/Form.
errorbooleanfalseApplies the error border color. Inherited from FormControl.
requiredbooleanfalseMarks the native select as required. Inherited from FormControl.
fullWidthbooleanfalseStretches the root to fill its container. Inherited from FormControl/Form.
borderRadiuskeyof Theme['radii']-Corner radius - applies only to default and outlined variants.
iconNameIconName'expand_more'Dropdown affordance icon from the Icon registry.
iconPropsOmit<IconProps, 'name'>-Extra props for the dropdown icon.
selectPropsSelectHTMLAttributes<HTMLSelectElement>-Extra attributes spread onto the native <select>. Explicit top-level props take priority.
id / namestring-Native passthrough. id is inherited from FormControl when omitted.

Also supports all space props (p, m, and directional variants) plus width / minWidth / maxWidth on the root.

Form integration

Wrap in FormControl to wire label, helper text, and shared field state automatically - resolution order is explicit prop → FormControl → Form → default:

<FormControl error fullWidth>
  <FormLabel>Platform</FormLabel>
  <NativeSelect options={platformOptions} placeholder="Pick a platform" />
  <FormHelperText>Pick the platform to deploy to.</FormHelperText>
</FormControl>

Notes

  • Implemented as a native <select> - there is no custom popover/listbox layer, so option rendering is limited to plain text labels.
  • The DOM casts option values to strings; onChange maps back to the original option value so value: 10 comes back as the number 10.
  • Multiple selection is intentionally not supported.

Source code

If this page does not answer your question, have a look at the implementation of the component for more detail.