Skip to main content
Version: Next 🚧

SelectList

SelectList is the searchable React Native list inside SelectPicker, as a standalone inline component. Use it in settings screens, onboarding steps, or your own sheets and modals.

import { SelectList } from '@elik56a/react-native-pickers';
Loading…
<View
  style={{
    borderWidth: 1,
    borderColor: '#E8E4DC',
    borderRadius: 16,
    paddingVertical: 8,
  }}
>
  <SelectList options={themes} value={mode} onChange={setMode} />
</View>

Try the props​

Platform
<SelectList
options={countries}
value={value}
onChange={setValue}
searchable
/>
Loading…
<SelectList
  multiple
  options={toppings}
  value={picked}
  onChange={setPicked}
  maxSelected={5}
  listHeight={320}
/>

Searching a server​

loadOptions loads the options for what the user types, with the loader showing from the keystroke until they arrive. Here the list starts with recent picks and searches a fake API:

Loading…
<SelectList
  multiple
  options={RECENT}
  loadOptions={searchPackages}
  value={packages}
  onChange={setPackages}
  searchPlaceholder="Search packages"
  loadingText="Searching the registry…"
  listHeight={300}
/>

Loading more as you scroll​

onEndReached fires near the end of the list; append the next page to options and set loading while it's on its way. The spinner shows under the options.

Loading…
<SelectList
  options={options}
  value={contact}
  onChange={setContact}
  searchable={false}
  loading={loading}
  loadingText="Loading contacts…"
  onEndReached={loadMore}
  listHeight={300}
/>

Behaviour​

  • Controlled only: pass value and update it in onChange.
  • In single mode, tapping an option calls onChange(value, option), including when it's already selected (there's no deselect).
  • In multiple mode, taps toggle. onChange(values, options) keeps selection order (appended at the end).
  • With maxSelected reached, unselected options become disabled until something is deselected.
  • Without listHeight, the list grows with its content. Inside a scroll view or sheet, give it a listHeight so it scrolls on its own.
  • Search state is internal and resets when the list unmounts; with onSearchChange, that reset calls onSearchChange('') so a remote list can drop its results.
  • For options from a server, see Search on a server: loadOptions, onSearchChange, loading and onEndReached work the same here.

Props​

PropTypeDefaultDescription
optionsReadonlyArray<SelectOption<T>>[]See options. With loadOptions, the ones shown before the user types.
multiplebooleanfalseMulti-select.
valueT | null · T[]—Selection.
onChange(value: T, option) => void · (values: T[], options) => void—Single · multiple.
maxSelectednumber—Multiple only.
searchablebooleanoptions.length > 8Show the search field.
querystring—Controlled search query, for filtering from your own input. Hides the built-in search field.
searchPlaceholderstring'Search'Search hint and its accessibility label.
filterOption(option: SelectOption<T>, query: string) => booleandefaultFilter; none with loadOptions / onSearchChangeCustom filter.
loadOptions(query: string) => Promise<SelectOption<T>[]>—Search a server: loader, debounce and stale answers handled.
onSearchChange(query: string) => void—Called once typing pauses, to search yourself.
searchPromptstring'Type to search'Shown before the user types, while a searched list has no options.
searchDebouncenumber300ms after the last keystroke before loadOptions / onSearchChange.
onEndReached() => void—Called near the end of the list, to load more.
loadingbooleanfalseSpinner in place of an empty list, or under the options.
loadingTextstring'Loading…'Text next to the spinner.
renderLoading(theme: PickerTheme) => ReactNode—Custom loader.
renderOption(info: SelectRenderOptionInfo<T>) => ReactNode—Custom row content.
renderGroupHeader(group: string, theme: PickerTheme) => ReactNode—Custom section header.
emptyTextstring'No results'Empty-state text.
showCheckmarksbooleantrue✓ (single) / checkbox (multiple).
isEqual(a: T, b: T) => booleanObject.isValue equality.
listHeightnumber—Fixed height for the scrolling list.
autoFocusSearchbooleanfalseFocus the search on mount.
styleStyleProp<ViewStyle>—Container style.
stylesSlotStyles<SelectSlot>—Slots below.
themeDeepPartial<PickerTheme>—Theme override.
design'ios' | 'material' | 'web'from PickersProviderThe look to follow, over the provider's: iOS, Material or web.
testIDstring—Test ID.

Slots​

SlotElement
containerOuter view
searchSearch field wrapper
searchInputThe TextInput
listThe FlatList
groupHeader / groupHeaderTextSection header
optionEach row
selectedOptionSelected rows (merged after option)
optionLabel / selectedOptionLabelRow label
optionDescriptionSecond line
check✓ or checkbox
empty / emptyTextEmpty state, and the searchPrompt
loading / loadingTextLoader row / its text

Types​

interface SelectRenderOptionInfo<T> { option: SelectOption<T>; selected: boolean; disabled: boolean; theme: PickerTheme }
type SelectValueProps<T> =
| { multiple?: false; value?: T | null; onChange?: (value: T, option: SelectOption<T>) => void }
| { multiple: true; value?: T[]; onChange?: (value: T[], options: SelectOption<T>[]) => void; maxSelected?: number };