# react-native-modal-datetime-picker
**Repository Path**: kevin402502/react-native-modal-datetime-picker
## Basic Information
- **Project Name**: react-native-modal-datetime-picker
- **Description**: A React-Native datetime-picker for Android and iOS
- **Primary Language**: JavaScript
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2021-06-17
- **Last Updated**: 2021-06-17
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# react-native-modal-datetime-picker
[](https://badge.fury.io/js/react-native-modal-datetime-picker)
[](https://github.com/prettier/prettier)
A declarative closs-platform react-native datetime-picker.
## Description
This library exposes a cross-platform interface for showing the native date and time pickers inside a modal.
You will have an unified user experience, you won't have to worry anymore about testing the device platform and you won't have to programmatically call the Android TimePicker/DatePicker APIs.
## Demo
## Setup
This library is available on npm, install it with `npm install --save react-native-modal-datetime-picker` or `yarn add react-native-modal-datetime-picker`.
## Usage
```javascript
import React, { Component } from 'react';
import { Text, TouchableOpacity, View } from 'react-native';
import DateTimePicker from 'react-native-modal-datetime-picker';
export default class DateTimePickerTester extends Component {
state = {
isDateTimePickerVisible: false,
};
_showDateTimePicker = () => this.setState({ isDateTimePickerVisible: true });
_hideDateTimePicker = () => this.setState({ isDateTimePickerVisible: false });
_handleDatePicked = (date) => {
console.log('A date has been picked: ', date);
this._hideDateTimePicker();
};
render () {
return (
Show TimePicker
);
}
}
```
## Available props
| Name | Type| Default | Description |
| --- | --- | --- | --- |
| cancelTextIOS | string | 'Cancel' | The text on the cancel button on iOS |
| confirmTextIOS | string | 'Confirm' | The text on the confirm button on iOS |
| customCancelButtonIOS | node | | A custom component for the cancel button on iOS |
| customConfirmButtonIOS | node | | A custom component for the confirm button on iOS |
| customTitleContainerIOS | node | | A custom component for the title container on iOS |
| datePickerContainerStyleIOS | style | | The style of the container on iOS |
| date | obj | new Date() | Initial selected date/time |
| isVisible | bool | false | Show the datetime picker? |
| mode | string | 'date' | Datepicker? 'date' Timepicker? 'time' Both? 'datetime' |
| datePickerModeAndroid | string | 'calendar' | Display as 'spinner' or 'calendar'|
| onConfirm | func | **REQUIRED** | Function called on date picked |
| onHideAfterConfirm | func | () => {} | Called after the hiding animation if a date was picked |
| onCancel | func | **REQUIRED** | Function called on dismiss |
| titleIOS | string | 'Pick a date' | The title text on iOS |
| minimumDate | Date | undefined | Min Date
| maximumDate | Date | undefined | Max Date
| is24Hour | bool | true | If false, the picker shows an AM/PM chooser on Android |
All the [DatePickerIOS props](https://facebook.github.io/react-native/docs/datepickerios.html) are also supported!
## Notes
Just remember to always set the `isVisible` prop to `false` in both `onConfirm` and `onCancel` (like in the example above).
Under the hood this library is using [react-native-modal](https://github.com/react-native-community/react-native-modal) for the iOS modal implementation.
Pull requests and suggestions are welcome!