1.0.2 • Published 1 year ago

searchable-dropdown-react-native v1.0.2

Weekly downloads
234
License
-
Repository
github
Last release
1 year ago

Searchable Dropdown React Native

Searchable Dropdown in react native, usable with Expo. Allow you to handle single and multiple selections.

Screenshots

first third second

Installation

npm install --save searchable-dropdown-react-native

Properties

NameDescriptionTypeDefaultRequired
optionsThe options for the component.arrayYes
selectedValuesThe values currently selected.arrayYes
setSelectedValuesThe callback to handle the selection of itemsfuncYes
labelThe label of the dropdownstringNo
placeholderDefault text to be shown to the userstring'Select an item'No
inputSizeSize of the input.number150No
addNewElementTextThe text that will be shown to add a new element is the options.stringAdd an itemNo
rightIconThe icon on the right of the input (if you want one).anyNo
selectedElementColorColor of the selected items.stringNo
labelStyleAdditional styles for the label.object{}No
containerStyleAdditional styles for the container view.object{}No
itemStyleAdditional styles for the items.object{}No
labelStyleAdditional styles for the labels.object{}No
inputContainerStyleAdditional styles for the input container.object{}No
inputColorThe color of the input.stringNo

Example

import React, { useState } from "react";
import SearchableDropdown from "searchable-dropdown-react-native";

let items = [
  {
    id: 1,
    name: "JavaScript",
    value: "JavaScript"
  },
  {
    id: 2,
    name: "Java",
    value: "Java"
  },
  {
    id: 3,
    name: "Ruby",
    value: "Ruby"
  },
  {
    id: 4,
    name: "React Native",
    value: "React Native"
  },
  {
    id: 5,
    name: "PHP",
    value: "PHP"
  },
  {
    id: 6,
    name: "Python",
    value: "Python"
  },
  {
    id: 7,
    name: "Go",
    value: "Go"
  },
  {
    id: 8,
    name: "Swift",
    value: "Swift"
  }
];

export default function App() {
  const [selectedValues, setSelectedValues] = useState([]);

  return (
    <SearchableDropdown
      options={items}
      selectedValues={selectedValues}
      setSelectedValues={setSelectedValues}
      label="test dropdown"
      placeholder="Test placeholder"
      inputSize={300}
    />
  );
}