Skip to content
Leslie edited this page May 27, 2025 · 6 revisions

All example code is written in TypeScript.

Importing what you need

Import the Selector component and Data type.

import Selector, { Data } from 'react-native-dropdown-selector';

Initialize your data

Define your Data array. The label field is required for each entry, but priority and data are optional.

const data: Data[] = [
  { label: 'Item 1' },
  { label: 'Item 2', data: { additionalParam: 'value' } },
  { label: 'Item 3', priority: true },
];

Define your onSelect function

Create a function that will be called every time an item gets selected. The parameter data is the item that was selected.

const onDataSelect = (data: Data) => {
  // Do something
};

Using the selector

Add a Selector component to your view using the previously created array and function.

<>
  <Selector.Select data={data} onSelect={onDataSelect} />
  {/* or use the MultiSelect component */}
  <Selector.MultiSelect data={data} onSelect={onMultiDataSelect} />
</>

That's it! Run your app to see the selector in action.

Clone this wiki locally