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

react-native-modal-selector

Package Overview
Dependencies
Maintainers
2
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-modal-selector

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

  • 2.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
168K
decreased by-5%
Maintainers
2
Weekly downloads
 
Created

What is react-native-modal-selector?

The react-native-modal-selector package provides a customizable modal selector component for React Native applications. It allows users to select an option from a list presented in a modal dialog, making it useful for dropdowns, pickers, and other selection interfaces.

What are react-native-modal-selector's main functionalities?

Basic Usage

This code demonstrates the basic usage of the react-native-modal-selector package. It shows how to create a modal selector with a list of options and handle the selection event.

import React, { useState } from 'react';
import { View, Text } from 'react-native';
import ModalSelector from 'react-native-modal-selector';

const App = () => {
  const [selectedItem, setSelectedItem] = useState('');
  const data = [
    { key: 1, label: 'Option 1' },
    { key: 2, label: 'Option 2' },
    { key: 3, label: 'Option 3' }
  ];

  return (
    <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
      <ModalSelector
        data={data}
        initValue="Select something"
        onChange={(option) => setSelectedItem(option.label)}
      />
      <Text>Selected: {selectedItem}</Text>
    </View>
  );
};

export default App;

Custom Styling

This code demonstrates how to apply custom styling to the modal selector and its text. It shows how to use the style and selectTextStyle props to customize the appearance of the selector.

import React, { useState } from 'react';
import { View, Text, StyleSheet } from 'react-native';
import ModalSelector from 'react-native-modal-selector';

const App = () => {
  const [selectedItem, setSelectedItem] = useState('');
  const data = [
    { key: 1, label: 'Option 1' },
    { key: 2, label: 'Option 2' },
    { key: 3, label: 'Option 3' }
  ];

  return (
    <View style={styles.container}>
      <ModalSelector
        data={data}
        initValue="Select something"
        onChange={(option) => setSelectedItem(option.label)}
        style={styles.selector}
        selectTextStyle={styles.selectText}
      />
      <Text style={styles.selectedText}>Selected: {selectedItem}</Text>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center'
  },
  selector: {
    backgroundColor: '#f0f0f0',
    borderRadius: 5,
    padding: 10
  },
  selectText: {
    color: '#333'
  },
  selectedText: {
    marginTop: 20,
    fontSize: 16
  }
});

export default App;

Pre-selected Value

This code demonstrates how to set a pre-selected value in the modal selector. The initValue prop is used to specify the initial selected value.

import React, { useState } from 'react';
import { View, Text } from 'react-native';
import ModalSelector from 'react-native-modal-selector';

const App = () => {
  const [selectedItem, setSelectedItem] = useState('Option 2');
  const data = [
    { key: 1, label: 'Option 1' },
    { key: 2, label: 'Option 2' },
    { key: 3, label: 'Option 3' }
  ];

  return (
    <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
      <ModalSelector
        data={data}
        initValue={selectedItem}
        onChange={(option) => setSelectedItem(option.label)}
      />
      <Text>Selected: {selectedItem}</Text>
    </View>
  );
};

export default App;

Other packages similar to react-native-modal-selector

Keywords

FAQs

Package last updated on 24 Oct 2022

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