MCPcopy Index your code
hub / github.com/azeezat/react-native-select

github.com/azeezat/react-native-select @v2.1.8

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.1.8 ↗ · + Follow
62 symbols 152 edges 42 files 2 documented · 3%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

NPM

npm version GitHub stars CodeQL Release & Publish to NPM coverage

react-native-input-select

A fully customizable dropdown selection package for react-native android and iOS with multiple select and search capabilities.

Installation

With npm

npm install react-native-input-select

With yarn

yarn add react-native-input-select

Sandbox

See more examples in Sandbox

iOS

Screenshot 2023-07-08 at 12 34 23 AM Screenshot 2023-07-08 at 12 39 51 AM Screenshot 2023-07-08 at 12 29 16 AM
Screenshot 2023-07-08 at 12 28 57 AM Screenshot 2023-07-08 at 12 20 52 AM Screenshot 2023-07-08 at 12 21 06 AM

Android

Screenshot 2023-05-16 at 6 17 09 AM Screenshot 2023-03-23 at 5 26 58 PM Screenshot 2023-03-23 at 5 28 49 PM

Basic Usage

import React from 'react';
import Dropdown from 'react-native-input-select';

export default function App() {
  const [country, setCountry] = React.useState();

  return (
    <Dropdown
      label="Country"
      placeholder="Select an option..."
      options={[
        { label: 'Nigeria', value: 'NG' },
        { label: 'Åland Islands', value: 'AX' },
        { label: 'Algeria', value: 'DZ' },
        { label: 'American Samoa', value: 'AS' },
        { label: 'Andorra', value: 'AD' },
      ]}
      selectedValue={country}
      onValueChange={(value) => setCountry(value)}
      primaryColor={'green'}
    />
  );
}

Advanced Usage With Flat List

import React from 'react';
import Dropdown from 'react-native-input-select';
import { View, StyleSheet, Text, Button, Alert, Image } from 'react-native';

export default function App() {
  const [country, setCountry] = React.useState();

  return (
    <Dropdown
      label="Customized components in list"
      placeholder="Select multiple countries..."
      options={countries.slice(0, 30)}
      optionLabel={'name'}
      optionValue={'code'}
      selectedValue={country}
      onValueChange={(itemValue: any) => setCountry(itemValue)}
      isMultiple
      isSearchable
      primaryColor={'orange'}
      dropdownStyle={{
        borderWidth: 0, // To remove border, set borderWidth to 0
      }}
      dropdownIcon={
        <Image
          style={styles.tinyLogo}
          source={{
            uri: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADMAAAAzCAYAAAA6oTAqAAAAEXRFWHRTb2Z0d2FyZQBwbmdjcnVzaEB1SfMAAABQSURBVGje7dSxCQBACARB+2/ab8BEeQNhFi6WSYzYLYudDQYGBgYGBgYGBgYGBgYGBgZmcvDqYGBgmhivGQYGBgYGBgYGBgYGBgYGBgbmQw+P/eMrC5UTVAAAAABJRU5ErkJggg==',
          }}
        />
      }
      dropdownIconStyle={{ top: 20, right: 20 }}
      listHeaderComponent={
        <View style={styles.customComponentContainer}>
          <Text style={styles.text}>
            💡 You can add any component to the top of this list
          </Text>
          <View style={styles.fixToText}>
            <Button
              title="Left button"
              onPress={() => Alert.alert('Left button pressed')}
              color="#007AFF"
            />
            <Button
              title="Right button"
              onPress={() => Alert.alert('Right button pressed')}
            />
          </View>
        </View>
      }
      listFooterComponent={
        <View style={styles.customComponentContainer}>
          <Text>You can add any component to the bottom of this list</Text>
        </View>
      }
      modalControls={{
        modalOptionsContainerStyle: {
          padding: 10,
          backgroundColor: 'cyan',
        },
        modalProps: {
          supportedOrientations: [
            'portrait',
            'portrait-upside-down',
            'landscape',
            'landscape-left',
            'landscape-right',
          ],
          transparent: false,
        },
      }}
      listComponentStyles={{
        listEmptyComponentStyle: {
          color: 'red',
        },
        itemSeparatorStyle: {
          opacity: 0,
          borderColor: 'white',
          borderWidth: 2,
          backgroundColor: 'cyan',
        },
        sectionHeaderStyle: {
          padding: 10,
          backgroundColor: 'cyan',
        },
      }}
      listControls={{
        selectAllText: 'Choose everything',
        unselectAllText: 'Remove everything',
        selectAllCallback: () => Alert.alert('You selected everything'),
        unselectAllCallback: () => Alert.alert('You removed everything'),
        emptyListMessage: 'No record found',
      }}
      selectedItemsControls={{
        removeItemIcon: (
          <Image
            source={{
              uri: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA',
            }}
            style={{ tintColor: 'white', height: 12, width: 12 }}
          />
        ),
        onRemoveItem: () => Alert.alert('Item was removed'),
        showRemoveIcon: true,
      }}
    />
  );
}

const styles = StyleSheet.create({
  customComponentContainer: {
    paddingHorizontal: 20,
    paddingVertical: 10,
  },
  text: {
    marginBottom: 20,
  },
  fixToText: {
    flexDirection: 'row',
    justifyContent: 'space-between',
  },
  tinyLogo: {
    width: 20,
    height: 20,
  },
  radioButton: {
    width: 20,
    height: 20,
    borderRadius: 20 / 2,
    borderWidth: 3,
    borderColor: 'white',
  },
});

Advanced Usage with Section List

<DropdownSelect
  label="Menu"
  placeholder="Select multiple dishes..."
  options={[
    {
      title: 'Main dishes',
      data: [
        { label: 'Pizza', value: 'A' },
        { label: 'Burger', value: 'B' },
        { label: 'Risotto', value: 'C' },
      ],
    },
    {
      title: 'Sides',
      data: [
        { label: 'Ice cream', value: 'D' },
        { label: 'Cheesecake', value: 'E' },
      ],
    },
    {
      title: 'Drinks',
      data: [
        { label: 'Water', value: 'F' },
        { label: 'Coke', value: 'G' },
        { label: 'Juice', value: 'H' },
      ],
    },
  ]}
  selectedValue={menu}
  onValueChange={(itemValue: any) => setMenu(itemValue)}
  isMultiple
  isSearchable
  primaryColor={'deepskyblue'}
  listComponentStyles={{
    sectionHeaderStyle: {
      padding: 10,
      backgroundColor: 'green',
      color: 'white',
      width: '30%',
    },
  }}
/>

For more examples visit our wiki page

Props

Proptypes Datatype Example
label string or ReactComponent Countries or <Text> You can add any component here <Text>
placeholder string Select a country
options Array [{ name: 'Nigeria', code: 'NG' }, { name: 'Albania', code: 'AL' }]
optionLabel string name
optionValue string code
error string This is a requiredfield
helperText string Only few countries are listed
selectedValue string or Array AL or [AL, AX]
onValueChange function ()=>{}
isMultiple Boolean true

Extension points exported contracts — how you extend this code

MyComponentProps (Interface)
(no doc)
example/src/WithClassComponent.tsx
DropdownSelectHandle (Interface)
(no doc)
src/types/index.types.ts
DropdownSelectedItemsContainerProps (Interface)
(no doc)
src/components/Dropdown/DropdownSelectedItemsContainer.tsx
UseIndexOfSelectedItemProps (Interface)
(no doc)
src/hooks/use-index-of-selected-item.ts
MyComponentState (Interface)
(no doc)
example/src/WithClassComponent.tsx
DropdownSelectedItemProps (Interface)
(no doc)
src/components/Dropdown/DropdownSelectedItem.tsx
UseCheckSelectAllProps (Interface)
(no doc)
src/hooks/use-select-all.ts
UseSearchProps (Interface)
(no doc)
src/hooks/use-search.ts

Core symbols most depended-on inside this repo

openModal
called by 7
src/hooks/use-modal.ts
closeModal
called by 5
src/hooks/use-modal.ts
removeDisabledItems
called by 4
src/utils/index.ts
extractPropertyFromArray
called by 3
src/utils/index.ts
logMovies
called by 2
example/src/App.tsx
scrollToLocation
called by 2
src/components/List/DropdownSectionList.tsx
scrollToItem
called by 2
src/components/List/DropdownFlatList.tsx
openActions
called by 2
src/components/Dropdown/DropdownSelectedItemsContainer.tsx

Shape

Function 39
Interface 10
Method 9
Class 4

Languages

TypeScript87%
Kotlin13%

Modules by API surface

example/src/WithClassComponent.tsx7 symbols
src/utils/index.ts6 symbols
src/components/List/DropdownSectionList.tsx5 symbols
example/android/app/src/main/java/com/inputselectexample/MainApplication.kt5 symbols
src/hooks/use-modal.ts4 symbols
src/components/Others/index.tsx4 symbols
src/components/List/DropdownFlatList.tsx4 symbols
src/hooks/use-search.ts3 symbols
src/components/Dropdown/DropdownSelectedItemsContainer.tsx3 symbols
example/android/app/src/main/java/com/inputselectexample/MainActivity.kt3 symbols
src/hooks/use-selection-handler.ts2 symbols
src/hooks/use-select-all.ts2 symbols

For agents

$ claude mcp add react-native-select \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact