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

react-native-paper-dropdown

Package Overview
Dependencies
Maintainers
0
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-paper-dropdown

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

  • 2.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6.1K
decreased by-22.56%
Maintainers
0
Weekly downloads
 
Created
Source

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

PropTypeDescription
testIDstringTest ID for the dropdown component.
menuTestIDstringTest ID for the dropdown menu.
valuestringThe currently selected value.
onSelect(value: string) => voidCallback function to handle value selection.
optionsOption[]Array of options for the dropdown.
menuUpIconJSX.ElementCustom icon for menu up state.
menuDownIconJSX.ElementCustom icon for menu down state.
maxMenuHeightnumberMaximum height of the dropdown menu.
menuContentStyleViewStyleStyle for the dropdown menu content.
CustomDropdownItem(props: DropdownItemProps) => JSX.ElementCustom component for dropdown item.
CustomDropdownInput(props: DropdownInputProps) => JSX.ElementCustom component for dropdown input.
CustomMenuHeader(props: DropdownHeaderProps) => JSX.ElementCustom component for the dropdown menu header.
TouchableForwardRefExoticComponent<PressableProps & RefAttributes<View>>Custom touchable component for the dropdown.
placeholderstringPlaceholder text for the dropdown input.
labelTextInputLabelPropLabel for the dropdown input.
mode'flat' | 'outlined'Mode for the dropdown input.
disabledbooleanWhether the dropdown is disabled.
errorbooleanWhether the dropdown has an error.
hideMenuHeaderbooleanHide menu header component (default: false).
statusBarHeightnumberAdditional top margin for the status bar on Android.

MultiSelectDropdownProps

PropTypeDescription
testIDstringTest ID for the dropdown component.
menuTestIDstringTest ID for the dropdown menu.
valuestring[]The currently selected values.
onSelect(value: string[]) => voidCallback function to handle value selection.
optionsOption[]Array of options for the dropdown.
menuUpIconJSX.ElementCustom icon for menu up state.
menuDownIconJSX.ElementCustom icon for menu down state.
TouchableForwardRefExoticComponent<PressableProps & RefAttributes<View>>Custom touchable component for the dropdown.
maxMenuHeightnumberMaximum height of the dropdown menu.
menuContentStyleViewStyleStyle for the dropdown menu content.
CustomMultiSelectDropdownItem(props: MultiSelectDropdownItemProps) => JSX.ElementCustom component for multi-select dropdown item.
CustomMultiSelectDropdownInput(props: DropdownInputProps) => JSX.ElementCustom component for multi-select dropdown input.
CustomMenuHeader(props: DropdownHeaderProps) => JSX.ElementCustom component for the dropdown menu header.
placeholderstringPlaceholder text for the dropdown input.
labelTextInputLabelPropLabel for the dropdown input.
mode'flat' | 'outlined'Mode for the dropdown input.
disabledbooleanWhether the dropdown is disabled.
errorbooleanWhether the dropdown has an error.
hideMenuHeaderbooleanHide menu header component (default: false).
statusBarHeightnumberAdditional top margin for the status bar on Android.

Methods

MethodReturnDescription
focus()voidOpen the dropdown manually.
blur()voidClose the dropdown manually.

Latest Documentation

v1 Documentation

fateh999




License

MIT

Keywords

FAQs

Package last updated on 02 Aug 2024

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