Socket
Socket
Sign inDemoInstall

react-native-date-picker

Package Overview
Dependencies
514
Maintainers
1
Versions
118
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-native-date-picker

A datetime picker for React Native. In-modal or inlined. Supports Android and iOS.


Version published
Weekly downloads
163K
increased by5.86%
Maintainers
1
Created
Weekly downloads
 

Package description

What is react-native-date-picker?

The react-native-date-picker package is a customizable date picker component for React Native applications. It allows users to select dates, times, or both, and provides various customization options to fit the design and functionality needs of the app.

What are react-native-date-picker's main functionalities?

Basic Date Picker

This code demonstrates a basic date picker where a button opens the date picker modal. The selected date is stored in the state.

import React, { useState } from 'react';
import { View, Button } from 'react-native';
import DatePicker from 'react-native-date-picker';

const App = () => {
  const [date, setDate] = useState(new Date());
  const [open, setOpen] = useState(false);

  return (
    <View>
      <Button title="Open Date Picker" onPress={() => setOpen(true)} />
      <DatePicker
        modal
        open={open}
        date={date}
        onConfirm={(date) => {
          setOpen(false);
          setDate(date);
        }}
        onCancel={() => {
          setOpen(false);
        }}
      />
    </View>
  );
};

export default App;

Time Picker

This code demonstrates a time picker where a button opens the time picker modal. The selected time is stored in the state.

import React, { useState } from 'react';
import { View, Button } from 'react-native';
import DatePicker from 'react-native-date-picker';

const App = () => {
  const [time, setTime] = useState(new Date());
  const [open, setOpen] = useState(false);

  return (
    <View>
      <Button title="Open Time Picker" onPress={() => setOpen(true)} />
      <DatePicker
        modal
        open={open}
        date={time}
        mode="time"
        onConfirm={(time) => {
          setOpen(false);
          setTime(time);
        }}
        onCancel={() => {
          setOpen(false);
        }}
      />
    </View>
  );
};

export default App;

Date and Time Picker

This code demonstrates a date and time picker where a button opens the date and time picker modal. The selected date and time are stored in the state.

import React, { useState } from 'react';
import { View, Button } from 'react-native';
import DatePicker from 'react-native-date-picker';

const App = () => {
  const [dateTime, setDateTime] = useState(new Date());
  const [open, setOpen] = useState(false);

  return (
    <View>
      <Button title="Open DateTime Picker" onPress={() => setOpen(true)} />
      <DatePicker
        modal
        open={open}
        date={dateTime}
        mode="datetime"
        onConfirm={(dateTime) => {
          setOpen(false);
          setDateTime(dateTime);
        }}
        onCancel={() => {
          setOpen(false);
        }}
      />
    </View>
  );
};

export default App;

Customizable Date Picker

This code demonstrates a customizable date picker where the text color and fade color are customized. The selected date is stored in the state.

import React, { useState } from 'react';
import { View, Button } from 'react-native';
import DatePicker from 'react-native-date-picker';

const App = () => {
  const [date, setDate] = useState(new Date());
  const [open, setOpen] = useState(false);

  return (
    <View>
      <Button title="Open Custom Date Picker" onPress={() => setOpen(true)} />
      <DatePicker
        modal
        open={open}
        date={date}
        onConfirm={(date) => {
          setOpen(false);
          setDate(date);
        }}
        onCancel={() => {
          setOpen(false);
        }}
        textColor="blue"
        fadeToColor="white"
        mode="date"
      />
    </View>
  );
};

export default App;

Other packages similar to react-native-date-picker

Readme

Source

React Native Date Picker

A cross platform react native date picker component for android and ios. It includes 3 different modes: date, time, and datetime. The date picker is customizable and has multiple language support.

Modal

The first option is to use the built-in modal.

React Native DateTime Picker Modal iOSReact Native DateTime Picker Modal Android
iOSAndroid

Inlined

The second option is to use the inlined picker. For instance in a view or a custom made modal.

React Native DateTime PickerReact Native Date Time Picker
iOSAndroid

Installation

See github page for installation instructions.

Documentation

See github page for documentation and more info.

Examples

See github page for code examples.

Modes

React Native Timepicker

react native timepicker react native timepicker android

More info about the react native timepicker.

React Native Datepicker

react native datepicker react native datepicker android

More info about the react native datepicker.

React Native Datetimepicker

React Native Date Picker react native datetimepicker react native datetimepicker android

More info about the react native datetimepicker.


Visit github page →

Keywords

FAQs

Last updated on 24 May 2024

Did you know?

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc