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

react-native-cross-picker

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-cross-picker

A fully customizable react native picker for android and ios

  • 1.2.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
increased by300%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-cross-picker

npm version

A Picker component for React Native which emulates the native <select> interfaces for iOS and Android

For iOS, Android or other platform this component looks same.

View examples on snack.expo.io

Getting Started

Installing

npm install react-native-cross-picker

Basic Usage

import React, { useState } from 'react';
import { StyleSheet, View } from 'react-native';
import { MaterialCommunityIcons } from "@expo/vector-icons"; // for expo and any other for react-native-cli

import ReactNativeCrossPicker from "react-native-cross-picker"


export default function Picker() {
  const [selectedItem, setItem] = useState('')

 const items = [
    { label: "label1", value: 1 },
    { label: "label2", value: 2 },
    { label: "label3", value: 3 },
    { label: "label4", value: 4 },
    { label: "label5", value: 5 },
    { label: "label6", value: 6 },
    { label: "label7", value: 7 },
    { label: "label8", value: 8 },
    { label: "label9", value: 9 },
  ]

  const iconComponent = () => {
    return <MaterialCommunityIcons
      name={"chevron-down"}
      size={20}
      color={"grey"}
    />
  }

  return (
    <View style={styles.container}>
      <ReactNativeCrossPicker
          modalTextStyle={{ color: "rgb(0, 74, 173)" }}
          mainComponentStyle={{ borderColor: "rgb(0, 74, 173)" }}
          iconComponent={iconComponent}
          items={items}
          setItem={setItem} selectedItem={selectedItem}
          placeholder="Select Item" 
          modalMarginTop={"50%"} // popup model margin from the top 
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#f2efef',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

Props

NameDescriptionDetails
setItemWill set the selected value to selectedItemrequired
useState hook
itemsThe items for the component to render
- Each item should be in the following format:
{label: 'Orange', value: 'orange'}
- label and value are required
- value can be any data type
-
required
array
placeholder- An override for the default placeholder, a label of Select itemstring
placeholderStyle- An override for the default placeholder stylestyle
modalTextStyleStyle overrides for text parts of the popup component.
style
modalComponentStyleStyle overrides the style of the popup component.
style
mainComponentStyleStyle overrides style of the main component.
style
modalBottomBorderColorAdditional props to pass to the Picker to display the bottom border of main componentcolor
iconComponentCustom icon component to be rendered.
function that return component
widthAdditional props to pass to the main component to set the width default will be 100%.number, percentage like width="80%".
placeholderDefault placeholder when item is not selectedstring
modalMarginTop
margin of the popup model from the top default will be 50%number, percentage etc.
modalMaxHeight
Maximum hight of the popup modalnumber, percentage etc.

License

react-native-cross-picker is MIT licensed and built with :heart: by Zahid Ali.

Keywords

FAQs

Package last updated on 22 Oct 2021

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