react-native-modal-selector vs react-native-picker-select vs react-native-dropdown-picker
React Native Dropdown Libraries Comparison
1 Year
react-native-modal-selectorreact-native-picker-selectreact-native-dropdown-picker
What's React Native Dropdown Libraries?

Dropdown libraries in React Native provide developers with customizable and user-friendly components to enhance the selection experience in mobile applications. These libraries facilitate the creation of dropdown menus that allow users to select options from a list, improving the overall user interface and interaction. Each library comes with unique features, design principles, and customization options, catering to different use cases and developer preferences.

NPM Package Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
react-native-modal-selector83,14836843.4 kB39-MIT
react-native-picker-select70,1851,77945.8 kB915 months agoMIT
react-native-dropdown-picker53,1941,007161 kB1632 years agoMIT
Feature Comparison: react-native-modal-selector vs react-native-picker-select vs react-native-dropdown-picker

Customization

  • react-native-modal-selector:

    react-native-modal-selector is designed for simplicity and elegance, offering limited but effective customization options. It allows developers to define the appearance of the modal and the items within it, focusing on a clean and user-friendly interface without overwhelming options.

  • react-native-picker-select:

    react-native-picker-select provides basic customization features such as placeholder text, style adjustments, and the ability to integrate with native pickers. It is lightweight and straightforward, making it easy to implement without extensive configuration.

  • react-native-dropdown-picker:

    This package offers extensive customization options, allowing developers to modify styles, colors, and behavior of the dropdown. It supports multi-select functionality, enabling users to select multiple items, and provides callbacks for various events, enhancing interactivity.

User Experience

  • react-native-modal-selector:

    This library emphasizes a clean and elegant user experience by presenting options in a modal view, reducing clutter on the screen. It provides a smooth transition and interaction, making it easy for users to navigate through options without distractions.

  • react-native-picker-select:

    With a focus on simplicity, react-native-picker-select offers a straightforward dropdown experience that integrates seamlessly with native components. It provides a familiar interface for users, ensuring quick and easy selections.

  • react-native-dropdown-picker:

    The user experience is enhanced through its intuitive design and support for multi-select options, which allows users to make multiple selections easily. The dropdown can be styled to match the app's theme, providing a cohesive look and feel.

Integration

  • react-native-modal-selector:

    react-native-modal-selector is easy to integrate into existing applications, requiring minimal setup. It can handle complex data structures, making it suitable for applications that need to display hierarchical or nested options.

  • react-native-picker-select:

    This package is designed for easy integration with React Native applications, leveraging the native picker component. It is particularly useful for projects that require a lightweight solution without additional dependencies.

  • react-native-dropdown-picker:

    It integrates well with various state management libraries, making it suitable for complex applications where dropdown selections need to be managed alongside other UI states. This integration capability enhances its versatility in larger projects.

Performance

  • react-native-modal-selector:

    Performance is generally good, but it may experience slight delays with very large datasets due to the modal presentation. It is best suited for moderate-sized lists to maintain a responsive user experience.

  • react-native-picker-select:

    As a lightweight component, react-native-picker-select offers excellent performance, especially for simple dropdowns. It leverages native components, ensuring fast rendering and minimal overhead.

  • react-native-dropdown-picker:

    The performance is optimized for handling large datasets, ensuring smooth interactions even with multiple selections. However, developers should be mindful of the rendering performance when dealing with extensive lists.

Community and Support

  • react-native-modal-selector:

    react-native-modal-selector has a smaller community compared to others, but it is still actively maintained. Documentation is clear, and support can be found through GitHub issues and community forums.

  • react-native-picker-select:

    With a robust community and extensive documentation, react-native-picker-select is well-supported. It has a larger user base, which contributes to a wealth of resources and examples for developers.

  • react-native-dropdown-picker:

    This package has a growing community and active maintenance, with regular updates and contributions. It is well-documented, providing ample resources for developers to troubleshoot and implement features effectively.

How to Choose: react-native-modal-selector vs react-native-picker-select vs react-native-dropdown-picker
  • react-native-modal-selector:

    Opt for react-native-modal-selector if you want a simple and elegant modal-based selector that can handle complex data structures and provides a clean user interface. This package is suitable for applications that prioritize ease of use and a straightforward selection process.

  • react-native-picker-select:

    Select react-native-picker-select when you need a lightweight and straightforward dropdown component that integrates well with React Native's native picker component. It is perfect for projects that require basic dropdown functionality with minimal overhead.

  • react-native-dropdown-picker:

    Choose react-native-dropdown-picker if you need a highly customizable dropdown component that supports multi-select options and offers a variety of styling options. It is ideal for applications requiring a visually appealing and flexible dropdown experience.

README for react-native-modal-selector

react-native-modal-selector npm version

A cross-platform (iOS / Android), selector/picker component for React Native that is highly customizable and supports sections.

This project is the official continuation of the abandoned react-native-modal-picker repo. Contributors are welcome to request a promotion to collaborator status.

Demo

Install

npm install react-native-modal-selector

Usage

You can either use this component in its default mode, as a wrapper around your existing component or provide a custom component (where you need to control opening of the modal yourself). In default mode a customizable button is rendered.

See SampleApp for an example how to use this component.

import ModalSelector from 'react-native-modal-selector'

class SampleApp extends Component {

    constructor(props) {
        super(props);

        this.state = {
            textInputValue: ''
        }
    }

    render() {
        let index = 0;
        const data = [
            { key: index++, section: true, label: 'Fruits' },
            { key: index++, label: 'Red Apples' },
            { key: index++, label: 'Cherries' },
            { key: index++, label: 'Cranberries', accessibilityLabel: 'Tap here for cranberries' },
            // etc...
            // Can also add additional custom keys which are passed to the onChange callback
            { key: index++, label: 'Vegetable', customKey: 'Not a fruit' }
        ];

        return (
            <View style={{flex:1, justifyContent:'space-around', padding:50}}>

                // Default mode
                <ModalSelector
                    data={data}
                    initValue="Select something yummy!"
                    onChange={(option)=>{ alert(`${option.label} (${option.key}) nom nom nom`) }} />

                // Wrapper
                <ModalSelector
                    data={data}
                    initValue="Select something yummy!"
                    supportedOrientations={['landscape']}
                    accessible={true}
                    scrollViewAccessibilityLabel={'Scrollable options'}
                    cancelButtonAccessibilityLabel={'Cancel Button'}
                    onChange={(option)=>{ this.setState({textInputValue:option.label})}}>

                    <TextInput
                        style={{borderWidth:1, borderColor:'#ccc', padding:10, height:30}}
                        editable={false}
                        placeholder="Select something yummy!"
                        value={this.state.textInputValue} />

                </ModalSelector>

                // Custom component
                <ModalSelector
                    data={data}
                    ref={selector => { this.selector = selector; }}
                    customSelector={<Switch onValueChange={() => this.selector.open()} />}
                />
            </View>
        );
    }
}

Data Format

The selector accepts a specific format of data:

[{ key: 5, label: 'Red Apples' }]

Optionally provide a component key which overrides the default label text. Optionally provide a unique testID for each item:

[{
  key: 5,
  label: 'Red Apples',
  // The next keys are optional --
  component: <View style={{backgroundColor: 'red'}}><Text style={{color: 'white'}}>Red Apples custom component ☺</Text></View>,
  testID: '5-red-apples'
}]

If your data has a specific format, you can define extractors of data, example:

this.setState({data: [{ id: 5, name: 'Red Apples' }]});

return (
  <ModalSelector
    data={this.state.data}
    keyExtractor= {item => item.id}
    labelExtractor= {item => item.name}
  />
);

API

Props

Prop | Type | Optional | Default | Description ------------------- | -------- | -------- | ------------ | ----------- data | array | No | [] | array of objects with a unique key and label to select in the modal. Optional component overrides label text. Optional unique testID for each item. onChange | function | Yes | () => {} | callback function, when the users has selected an option onModalOpen | function | Yes | () => {} | callback function, when modal is opening onModalClose | function | Yes | (item) => {} | callback function, when modal is closing. Returns the selected item. keyExtractor      | function | Yes     | (data) => data.key   | extract the key from the data item labelExtractor    | function | Yes     | (data) => data.label | extract the label from the data item componentExtractor| function | Yes     | (data) => data.component | extract the component from the data item visible | bool | Yes | false | control open/close state of modal closeOnChange | bool | Yes | true | control if modal closes on select initValue | string | Yes | Select me! | text that is initially shown on the button cancelText | string | Yes | cancel | text of the cancel button disabled | bool | Yes | false | true disables opening of the modal supportedOrientations | ['portrait', 'landscape'] | Yes | both | orientations the modal supports keyboardShouldPersistTaps| string / bool | Yes | always | passed to underlying ScrollView listType | string | Yes | SCROLLVIEW | scroller type: SCROLLVIEW or FLATLIST animationType | string | Yes | slide | type of animation to be used to show the modal. Must be one of none, slide or fade. style | object | Yes | | style definitions for the root element childrenContainerStyle| object | Yes | {} | style definitions for the children container view touchableStyle | object | Yes | {} | style definitions for the touchable element touchableActiveOpacity | number | Yes | 0.2 | opacity for the touchable element on touch selectStyle       | object   | Yes     | {}         | style definitions for the select element (available in default mode only!). NOTE: Due to breaking changes in React Native, RN < 0.39.0 should pass flex:1 explicitly to selectStyle as a prop. selectTextStyle | object | Yes | {} | style definitions for the select element (available in default mode only!) overlayStyle | object | Yes | { flex: 1, padding: '5%', justifyContent: 'center', backgroundColor: 'rgba(0,0,0,0.7)' } | style definitions for the overlay background element. RN <= 0.41 should override this with pixel value for padding. sectionStyle | object | Yes | {} | style definitions for the section element sectionTextStyle | object | Yes | {} | style definitions for the select text element selectedItemTextStyle | object | Yes | {} | style definitions for the currently selected text element optionStyle | object | Yes | {} | style definitions for the option element optionTextStyle | object | Yes | {} | style definitions for the option text element optionContainerStyle| object | Yes | {} | style definitions for the option container element cancelStyle | object | Yes | {} | style definitions for the cancel element cancelTextStyle | object | Yes | {} | style definitions for the cancel text element initValueTextStyle| object | Yes | {} | style definitions for the initValue text element cancelContainerStyle| object | Yes | {} | style definitions for the cancel container backdropPressToClose| bool | Yes | false | true makes the modal close when the overlay is pressed passThruProps| object | Yes | {} | props to pass through to the container View and each option TouchableOpacity (e.g. testID for testing) selectTextPassThruProps| object | Yes | {} | props to pass through to the select text component optionTextPassThruProps| object | Yes | {} | props to pass through to the options text components in the modal cancelTextPassThruProps| object | Yes | {} | props to pass through to the cancel text components in the modal scrollViewPassThruProps| object | Yes | {} | props to pass through to the internal ScrollView openButtonContainerAccessible| bool | Yes | false | true enables accessibility for the open button container. Note: if false be sure to define accessibility props directly in the wrapped component. listItemAccessible| bool | Yes | false | true enables accessibility for data items. Note: data items should have an accessibilityLabel property if this is enabled cancelButtonAccessible| bool | Yes | false | true enables accessibility for cancel button. scrollViewAccessible| bool | Yes | false | true enables accessibility for the scroll view. Only enable this if you don't want to interact with individual data items. scrollViewAccessibilityLabel | string | Yes | undefined | Accessibility label for the modal ScrollView cancelButtonAccessibilityLabel | string | Yes | undefined | Accessibility label for the cancel button modalOpenerHitSlop | object | Yes | {} | How far touch can stray away from touchable that opens modal (RN docs) customSelector | node | Yes | undefined | Render a custom node instead of the built-in select box. selectedKey | any | Yes | '' | Key of the item to be initially selected enableShortPress | bool | Yes | true | enables short press. This is regular touch behavior. enableLongPress | bool | Yes | false | enables long press. When true, onModalOpen returns {longPress: true} optionsTestIDPrefix | string | Yes | 'default' | This prefixes each selectable option's testID prop if no testID keys are provided in props.data array objects. Default for each option's testID: 'default-<optionLabel>' header | node | Yes | undefined | Render a header above the list onEndReached | function | Yes | undefined | Called once when the scroll position gets of the rendered content.

Methods

  • open(): open the modal.
  • close(): close the modal.
  • getSelectedItem(): get current selected item, updated by onChange event.

See also