Socket
Socket
Sign inDemoInstall

react-native-dropdown-select-list

Package Overview
Dependencies
0
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-dropdown-select-list

⭐ React Native Select List Equivalent to Html's Select with options"


Version published
Maintainers
1
Weekly downloads
6,836
decreased by-15.8%
Install size
45.6 kB

Weekly downloads

Readme

Source
NPM VERSIONNPM WEEKLY DOWNLOADSGITHUB STARYOUTUBE VIEWSNPM LIFETIME DOWNLOADS

⭐ React Native Dropdown Select List

React Native Select List Equivalent to Html's Select "

Multiple Select ListSelect List


Light weight and Easy to use dropdown select list.
  • Style it your way with style props of every view.
  • Smooth performance on all platforms IOS, Android and Web.
  • Change Font Family Easily which community picker lacks.
  • Zero dependencies

Compatibility


iOSAndroidWebExpo

🔌 Installation

$ npm install react-native-dropdown-select-list

OR

$ yarn add react-native-dropdown-select-list

😎 Basic Usage for SelectList

import { SelectList } from 'react-native-dropdown-select-list'

const App = () => {

  const [selected, setSelected] = React.useState("");
  
  const data = [
      {key:'1', value:'Mobiles', disabled:true},
      {key:'2', value:'Appliances'},
      {key:'3', value:'Cameras'},
      {key:'4', value:'Computers', disabled:true},
      {key:'5', value:'Vegetables'},
      {key:'6', value:'Diary Products'},
      {key:'7', value:'Drinks'},
  ]

  return(
    <SelectList 
        setSelected={(val) => setSelected(val)} 
        data={data} 
        save="value"
    />
  )

};

😎 Basic Usage for MultipleSelectList

import { MultipleSelectList } from 'react-native-dropdown-select-list'

const App = () => {

  const [selected, setSelected] = React.useState([]);
  
  const data = [
      {key:'1', value:'Mobiles', disabled:true},
      {key:'2', value:'Appliances'},
      {key:'3', value:'Cameras'},
      {key:'4', value:'Computers', disabled:true},
      {key:'5', value:'Vegetables'},
      {key:'6', value:'Diary Products'},
      {key:'7', value:'Drinks'},
  ]

  return(
    <MultipleSelectList 
        setSelected={(val) => setSelected(val)} 
        data={data} 
        save="value"
        onSelect={() => alert(selected)} 
        label="Categories"
    />
  )

};

For Live Demo (Expo Snack)


🔧 General Props

Applicable on both SelectList & MultipleSelectList Components

NameTypeDescription
savestringPass ('key' or 'value') to save data of your choice in your local state variable
onSelectFunctionPass any function that you want to trigger immediately after a value is selected
placeholderStringPlaceholder text that will be displayed in the select box
searchbooleanset to false if you dont want to use search functionality
maxHeightNumberMaximum height of the dropdown wrapper to occupy
dataarray or array[object]Data which will be iterated as options of select list
setSelectedFunctionFor Setting the option value which will be stored in your local state
searchiconJSX ElementPass any JSX to this prop like Text, Image or Icon to show instead of search icon
arrowiconJSX ElementPass any JSX to this prop like Text, Image or Icon to show instead of chevron icon
closeiconJSX ElementPass any JSX to this prop like Text, Image or Icon to show instead of close icon
searchPlaceholderStringCustom placeholder text for search TextInput
defaultOptionObjectPass default selected option in key value pair
fontFamilystringPass font name to apply globally on each text field of component
notFoundTextstringPass your custom message if any search result returns empty
dropdownShownbooleanControl your dropdown ( on & off ) state by changing its value to true or false

🔧 General Style Props

Applicable on both SelectList & MultipleSelectList Components

NameTypeDescription
boxStylesObjectAdditional styles for select box parent wrapper
inputStylesObjectAdditional styles for text of selection box
dropdownStylesObjectAdditional styles for dropdown scrollview
dropdownItemStylesObjectAdditional styles for dropdown single list item
dropdownTextStylesObjectAdditional styles for dropdown list items text
disabledItemStylesObjectAdditional styles for disabled dropdown list item
disabledTextStylesObjectAdditional styles for disabled dropdown list items text

😎 Advanced Usage

import { SelectList } from 'react-native-dropdown-select-list'

const App = () => {

  const [selected, setSelected] = React.useState("");
  
  const data = [
    {key:'1',value:'Jammu & Kashmir'},
    {key:'2',value:'Gujrat'},
    {key:'3',value:'Maharashtra'},
    {key:'4',value:'Goa'},
  ];

  return(
    <SelectList 
      onSelect={() => alert(selected)}
      setSelected={setSelected} 
      fontFamily='lato'
      data={data}  
      arrowicon={<FontAwesome name="chevron-down" size={12} color={'black'} />} 
      searchicon={<FontAwesome name="search" size={12} color={'black'} />} 
      search={false} 
      boxStyles={{borderRadius:0}} //override default styles
      defaultOption={{ key:'1', value:'Jammu & Kashmir' }}   //default selected option
    />
  )

};

😎 Getting Options From Database

import { SelectList } from 'react-native-dropdown-select-list'

const App = () => {

  const [selected, setSelected] = React.useState("");
  const [data,setData] = React.useState([]);
  
  React.useEffect(() => 
    //Get Values from database
    axios.get('https://jsonplaceholder.typicode.com/users')
      .then((response) => {
        // Store Values in Temporary Array
        let newArray = response.data.map((item) => {
          return {key: item.id, value: item.name}
        })
        //Set Data Variable
        setData(newArray)
      })
      .catch((e) => {
        console.log(e)
      })
  ,[])

  return(
    <SelectList setSelected={setSelected} data={data} onSelect={() => alert(selected)} />
  )

};

🔧 Additional Props

Applicable on MultipleSelectList Only

NameTypeDescription
labelstringPass any string to be placed instead of default label

🔧 Additional Style Props

Applicable on MultipleSelectList Only

NameTypeDescription
disabledCheckBoxStylesObjectAdditional styles disabled checkbox inside dropdown
checkBoxStylesObjectAdditional styles for active checkbox
badgeStylesObjectAdditional styles for badges of selected values
badgeTextStylesObjectAdditional styles for Text of badges of selected values
labelStylesObjectAdditional styles for label of multiple select list

▶️ Watch Video

Watch the video


💲 Would you like to support me?

If you would like me come up with similar packages, buy me a cup of coffee to boost my energy.

Paypal

For Live Demo (Expo Snack)


Keywords

FAQs

Last updated on 22 Aug 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc