1.8.0 • Published 6 years ago

@leonardodino/react-native-datepicker v1.8.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

react-native-datepicker

npm version Build Status

react-native DatePicker component for Android and iOS

Install

npm install --save @leonardodino/react-native-datepicker

or

yarn add @leonardodino/react-native-datepicker

Screenshots

android ios

Usage

import React, { Component } from 'react'
import DatePicker from 'react-native-datepicker'

export default class MyDatePicker extends Component {
  state = {date: new Date('2016-05-15')}

  render(){
    return (
      <DatePicker
        style={{width: 200}}
        date={this.state.date}
        mode='date'
        placeholder='select date'
        minDate={new Date('2016-05-01')}
        maxDate={new Date('2016-06-01')}
        confirmBtnText='Confirm'
        cancelBtnText='Cancel'
        customStyles={{
          dateInput: {
            marginLeft: 36
          }
          // ... You can check the source to find the other keys.
        }}
        onDateChange={(date) => {this.setState({date})}}
      />
    )
  }
}

Properties

PropDefaultTypeDescription
style-objectSpecify the style of the DatePicker, eg. width, height...
date-dateSpecify the display date of DatePicker.
mode'date'enumThe enum of date, datetime and time
androidMode'default'enumThe enum of default, calendar and spinner (only Android)
confirmBtnText'Confirm'stringSpecify the text of confirm btn in ios.
cancelBtnText'Cancel'stringSpecify the text of cancel btn in ios.
locale'en'stringSpecify the bcp47 locale for display.
minDate-dateRestricts the range of possible date values.
maxDate-dateRestricts the range of possible date values.
duration300numberSpecify the animation duration of datepicker.
customStyles-numberThe hook of customize datepicker style, same as the native style. dateTouchBody, dateInput...
hideTextfalsebooleanController whether or not show the dateText
disabledfalsebooleanController whether or not disable the picker
placeholder''stringThe placeholder show when this.props.date is falsy
onDateChange-functionThis is called when the user confirm the picked date or time in the UI.
onOpenModal-functionThis is called when the DatePicker Modal open.
onCloseModal-functionThis is called when the DatePicker Modal close
onPressMask-functionThis is called when clicking the ios Modal mask
modalOnResponderTerminationRequest-functionSet the callback for React Native's Gesture Responder System's call to onResponderTerminationRequest. By default this will reject a termination request, but can be overidden in case the View under the Modal is implementing custom gesture responders, and you wish for those to be overidden in certain cases.
TouchableComponentTouchableHighlightComponentReplace the TouchableHighlight with a custom Component. For example : TouchableOpacity

Property customStyles available keys

  • appearance: dateInput, disabled, dateTouchBody, placeholderText, dateText
  • ios select panel: datePickerCon, datePicker, btnConfirm, btnTextConfirm, btnCancel, btnTextCancel
1.8.0

6 years ago

1.7.5

7 years ago

1.7.4

7 years ago

1.7.3

7 years ago

1.7.2

7 years ago

1.7.1

7 years ago

1.7.0

7 years ago

1.6.1

7 years ago