Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-input-select

Package Overview
Dependencies
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-input-select

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

  • 0.34.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2K
increased by9.33%
Maintainers
1
Weekly downloads
 
Created
Source

CodeQL

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

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={[
        { name: 'Albania', code: 'AL' },
        { name: 'Åland Islands', code: 'AX' },
        { name: 'Algeria', code: 'DZ' },
        { name: 'American Samoa', code: 'AS' },
        { name: 'Andorra', code: 'AD' },
        { name: 'Angola', code: 'AO' },
        { name: 'Anguilla', code: 'AI' },
        { name: 'Antarctica', code: 'AQ' },
        { name: 'Antigua and Barbuda', code: 'AG' },
      ]}
      optionLabel={'name'}
      optionValue={'code'}
      selectedValue={country}
      onValueChange={(value) => setCountry(value)}
      primaryColor={'green'}
    />
  );
}

Advanced Usage

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 options..."
      options={countries.slice(0, 3)}
      optionLabel={'name'}
      optionValue={'code'}
      selectedValue={country}
      onValueChange={(itemValue: any) => setCountry(itemValue)}
      isMultiple
      primaryColor={'orange'}
      dropdownStyle={{
        borderWidth: 0, // To remove border, set borderWidth to 0
      }}
      placeholderStyle={{
        color: 'purple',
        fontSize: 15,
        fontWeight: '500',
      }}
      labelStyle={{ color: 'teal', fontSize: 15, fontWeight: '500' }}
      dropdownHelperTextStyle={{
        color: 'green',
        fontWeight: '900',
      }}
      modalBackgroundStyle={{
        backgroundColor: 'rgba(196, 198, 246, 0.5)',
      }}
      helperText="The placeholder has been styled"
      checkboxSize={20}
      checkboxStyle={{
        backgroundColor: 'purple',
        borderRadius: 30, // To get a circle - add the checkboxSize and the padding size
        padding: 10,
      }}
      checkboxLabelStyle={{ color: 'red', fontSize: 30 }}
      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>
      }
      modalOptionsContainerStyle={{ padding: 10, backgroundColor: 'cyan' }}
    />
  );
}

const styles = StyleSheet.create({
  customComponentContainer: {
    paddingHorizontal: 20,
    paddingVertical: 10,
  },
  text: {
    marginBottom: 20,
  },
  fixToText: {
    flexDirection: 'row',
    justifyContent: 'space-between',
  },
  tinyLogo: {
    width: 20,
    height: 20,
  },
});

For more examples visit our wiki page

iOS

Screenshot 2023-04-18 at 10 06 15 AMScreenshot 2023-03-23 at 5 00 19 PMScreenshot 2023-03-23 at 5 00 29 PM
Screenshot 2023-03-23 at 5 00 35 PMScreenshot 2023-03-23 at 5 11 54 PMScreenshot 2023-04-06 at 5 26 46 PM

Android

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

Props

ProptypesDatatypeExample
labelstringCountries
placeholderstringSelect a country
optionsArray[{ name: 'Nigeria', code: 'NG' }, { name: 'Albania', code: 'AL' }]
optionLabelstringname
optionValuestringcode
errorstringThis is a requiredfield
helperTextstringOnly few countries are listed
selectedValuestring or ArrayAL or [AL, AX]
onValueChangefunction()=>{}
isMultipleBooleantrue
isSearchableBooleantrue
disabledBooleantrue
dropdownIconReact ComponentImage or <Text> Show <Text>
labelStyleObject{color: 'red', fontSize: 15, fontWeight: '500'}
placeholderStyleObject{color: 'blue', fontSize: 15, fontWeight: '500'}
dropdownStyleObject{borderColor: 'blue', margin: 5, borderWidth:0 ...}
dropdownContainerStyleObject{backgroundColor: 'red', width: '30%', ...}
dropdownIconStyleObject{top: 10 , right: 10, ...}
searchInputStyleObject{backgroundColor: 'red', borderRadius: 0, ...}
selectedItemStyleObject{fontWeight: '600', color: 'yellow', ...}
multipleSelectedItemStyleObject{backgroundColor: 'red', color: 'yellow', ...}
modalBackgroundStyleObject{backgroundColor: 'rgba(196, 198, 246, 0.5)'}
modalOptionsContainerStyleObject{padding: 10, backgroundColor: 'cyan',}
modalPropsReactNative.ModalProps{supportedOrientations:{['landscape-left', landscape-right']}
dropdownErrorStyleObject{borderWidth: 2, borderStyle: 'solid'}
dropdownErrorTextStyleObject{color: 'red', fontWeight:'500'}
dropdownHelperTextStyleObject{color: 'green', fontWeight:'500'}
primaryColorstringblue
checkboxSizenumber20
checkboxStyleObject{backgroundColor: 'blue', borderRadius: 30, padding: 10}
checkboxLabelStyleObject{color: 'red', fontWeight:'500'}
listHeaderComponentReact Component<Text> You can add any component here
listFooterComponentReact Component<Text> You can add any component here
hideModalBooleanUse this to hide the modal as needed

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

Made with contrib.rocks.

License

MIT

Video Demo

https://user-images.githubusercontent.com/9849221/232344214-55fa5557-cfdd-42c4-a334-f93c15341b0b.mov

Keywords

FAQs

Package last updated on 15 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc