npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-paper-dropdown

v2.3.1

Published

Dropdown component using React Native Paper TextInput and Menu, now also with multiselect

Downloads

30,519

Readme

react-native-paper-dropdown

npm version npm downloads npm npm

Material Design Dropdown Component using React Native Paper, now also with multiselect

Dependencies

react-native-paper

Installation

yarn add react-native-paper-dropdown

or

npm i react-native-paper-dropdown

Demo

Basic Example

Single Select

import React, { useState } from 'react';
import { View } from 'react-native';
import { Dropdown } from 'react-native-paper-dropdown';
import { Provider as PaperProvider } from 'react-native-paper';

const OPTIONS = [
  { label: 'Male', value: 'male' },
  { label: 'Female', value: 'female' },
  { label: 'Other', value: 'other' },
];

export default function App() {
  const [gender, setGender] = useState<string>();

  return (
    <PaperProvider>
      <View style={{ margin: 16 }}>
        <Dropdown
          label="Gender"
          placeholder="Select Gender"
          options={OPTIONS}
          value={gender}
          onSelect={setGender}
        />
      </View>
    </PaperProvider>
  );
}

Multi Select

import React, { useState } from 'react';
import { View } from 'react-native';
import { MultiSelectDropdown } from 'react-native-paper-dropdown';
import { Provider as PaperProvider } from 'react-native-paper';

const MULTI_SELECT_OPTIONS = [
  { label: 'White', value: 'white' },
  { label: 'Red', value: 'red' },
  { label: 'Blue', value: 'blue' },
  { label: 'Green', value: 'green' },
  { label: 'Orange', value: 'orange' },
];

export default function App() {
  const [colors, setColors] = useState<string[]>([]);

  return (
    <PaperProvider>
      <View style={{ margin: 16 }}>
        <MultiSelectDropdown
          label="Colors"
          placeholder="Select Colors"
          options={MULTI_SELECT_OPTIONS}
          value={colors}
          onSelect={setColors}
        />
      </View>
    </PaperProvider>
  );
}

Props

DropdownProps

| Prop | Type | Description | | --------------------- | ----------------------------------------------------------------- | ---------------------------------------------------- | | testID | string | Test ID for the dropdown component. | | menuTestID | string | Test ID for the dropdown menu. | | value | string | The currently selected value. | | onSelect | (value: string) => void | Callback function to handle value selection. | | options | Option[] | Array of options for the dropdown. | | menuUpIcon | JSX.Element | Custom icon for menu up state. | | menuDownIcon | JSX.Element | Custom icon for menu down state. | | maxMenuHeight | number | Maximum height of the dropdown menu. | | menuContentStyle | ViewStyle | Style for the dropdown menu content. | | CustomDropdownItem | (props: DropdownItemProps) => JSX.Element | Custom component for dropdown item. | | CustomDropdownInput | (props: DropdownInputProps) => JSX.Element | Custom component for dropdown input. | | CustomMenuHeader | (props: DropdownHeaderProps) => JSX.Element | Custom component for the dropdown menu header. | | Touchable | ForwardRefExoticComponent<PressableProps & RefAttributes<View>> | Custom touchable component for the dropdown. | | placeholder | string | Placeholder text for the dropdown input. | | label | TextInputLabelProp | Label for the dropdown input. | | mode | 'flat' \| 'outlined' | Mode for the dropdown input. | | disabled | boolean | Whether the dropdown is disabled. | | error | boolean | Whether the dropdown has an error. | | hideMenuHeader | boolean | Hide menu header component (default: false). | | statusBarHeight | number | Additional top margin for the status bar on Android. |

MultiSelectDropdownProps

| Prop | Type | Description | | -------------------------------- | ----------------------------------------------------------------- | ---------------------------------------------------- | | testID | string | Test ID for the dropdown component. | | menuTestID | string | Test ID for the dropdown menu. | | value | string[] | The currently selected values. | | onSelect | (value: string[]) => void | Callback function to handle value selection. | | options | Option[] | Array of options for the dropdown. | | menuUpIcon | JSX.Element | Custom icon for menu up state. | | menuDownIcon | JSX.Element | Custom icon for menu down state. | | Touchable | ForwardRefExoticComponent<PressableProps & RefAttributes<View>> | Custom touchable component for the dropdown. | | maxMenuHeight | number | Maximum height of the dropdown menu. | | menuContentStyle | ViewStyle | Style for the dropdown menu content. | | CustomMultiSelectDropdownItem | (props: MultiSelectDropdownItemProps) => JSX.Element | Custom component for multi-select dropdown item. | | CustomMultiSelectDropdownInput | (props: DropdownInputProps) => JSX.Element | Custom component for multi-select dropdown input. | | CustomMenuHeader | (props: DropdownHeaderProps) => JSX.Element | Custom component for the dropdown menu header. | | placeholder | string | Placeholder text for the dropdown input. | | label | TextInputLabelProp | Label for the dropdown input. | | mode | 'flat' \| 'outlined' | Mode for the dropdown input. | | disabled | boolean | Whether the dropdown is disabled. | | error | boolean | Whether the dropdown has an error. | | hideMenuHeader | boolean | Hide menu header component (default: false). | | statusBarHeight | number | Additional top margin for the status bar on Android. |

Methods

| Method | Return | Description | | --------- | ------ | ---------------------------- | | focus() | void | Open the dropdown manually. | | blur() | void | Close the dropdown manually. |

Latest Documentation

v1 Documentation

License

MIT