Skip to main content

Select

A pressable field that opens a bottom sheet of options. Fully controlled via value and onChange.

Basic usage​

Fruit
function SelectDemo() {
const [value, setValue] = useState('apple');

return (
<Select
label="Fruit"
placeholder="Choose a fruit…"
value={value}
onChange={setValue}
options={[
{ label: 'Apple', value: 'apple' },
{ label: 'Banana', value: 'banana' },
{ label: 'Cherry', value: 'cherry' },
]}
/>
);
}

Invalid & disabled​

Country
This field is required
<Select
label="Country"
placeholder="Select a country…"
value={value}
onChange={setValue}
isInvalid
errorText="This field is required"
options={[
{ label: 'India', value: 'in' },
{ label: 'USA', value: 'us' },
]}
/>

Custom icons​

By default the trigger shows a plain ▲/▼ glyph and the selected option shows a plain ✓ glyph. Pass icon and checkIcon to use real icons instead: either accepts any component matching TVajraIconComponent.

Fruit
import { ChevronDownIcon, CheckIcon } from '@88khp/vajra-icons';

<Select
label="Fruit"
value={value}
onChange={setValue}
icon={ChevronDownIcon}
checkIcon={CheckIcon}
options={options}
/>

Multiple selection​

Pass multiple to select more than one option; value becomes an array and onChange receives the full updated array on each toggle.

Fruits
const [value, setValue] = useState<string[]>(['apple']);

<Select multiple label="Fruits" value={value} onChange={setValue} options={options} />

Searchable​

Pass isSearchable to show a filter field above the options list, filtering by label.

Country
<Select isSearchable label="Country" value={value} onChange={setValue} options={options} />

Props​

PropTypeDefaultDescription
options{ label: string; value: TValue }[]Required. List of selectable options.
multiplebooleanfalseSwitches to multi-select mode — value becomes TValue[] and onChange receives TValue[].
valueTValue | TValue[]Currently selected value(s); an array when multiple.
onChange(value: TValue) => void | (value: TValue[]) => voidRequired. Called when selection changes.
placeholderstring'Select…'Text shown when nothing is selected.
labelstringLabel rendered above the field.
errorTextstringHelper text shown below the field when isInvalid.
isInvalidbooleanfalseRenders the field with an error border and shows errorText.
isDisabledbooleanfalseDisables interaction and dims opacity.
selectedColorTVajraColors'primary'Highlight color for the selected option(s) in the sheet.
iconTVajraIconComponentIcon shown at the trailing edge of the trigger, rotated between open/closed state. Defaults to a plain ▲/▼ glyph.
checkIconTVajraIconComponentIcon shown next to selected option(s) in the sheet. Defaults to a plain ✓ glyph.
isSearchablebooleanfalseShows a filter field above the options list, filtering by label.
searchPlaceholderstring'Search…'Placeholder for the search field.
searchIconTVajraIconComponentIcon shown at the start of the search field.
testIDstringTest identifier.