React Native DatePicker component for both Android and iOS, useing DatePickerAndroid, TimePickerAndroid and DatePickerIOS
npm install react-native-cn-datepickerTalk to us about more commands if you need
⚡ Install
``bash`
npm i react-native-cn-datepicker`
orbash`
yarn add react-native-cn-datepicker
⚡ npm run pod
`bash`
npx pod-install ios
⚡ Usage
`javascript
import DatePicker from 'react-native-cn-datepicker'
render(){
return (
date={this.state.date}
mode="date"
placeholder="select date"
format="DD-MM-YYYY"
display="spinner"
is24Hour={false}
confirmBtnText="Confirm"
cancelBtnText="Cancel"
customStyles={{
placeholderText: {
fontSize: 18,
color: "#48515B"
},
dateText:{
fontSize: 18
},
dateInput: {
marginLeft: 36
}
}}
onDateChange={(date) => {
console.log(date);
}}
locale={"en"} // Default en
/>
)
}
}
`object
⚡ Properties
| Prop | Default | Type | Description |
| :------------ |:---------------:| :---------------:| :-----|
| style | - | | Specify the style of the DatePicker, eg. width, height... |string
| date | - | string | date | Moment instance | Specify the display date of DatePicker. type value must match the specified format |enum
| mode | 'date' | | The enum of date, datetime and time |enum
| androidMode | 'default' | | The enum of default, calendar and spinner (only Android) |string
| format | 'YYYY-MM-DD' | | Specify the display format of the date, which using moment.js. The default value change according to the mode. |string
| confirmBtnText | 'Confirm' | | Specify the text of confirm btn in ios. |string
| cancelBtnText | 'Cancel' | | Specify the text of cancel btn in ios. |number
| duration | 300 | | Specify the animation duration of datepicker.|object
| customStyles | - | | The hook of customize datepicker style, same as the native style. dateTouchBody, dateInput...|boolean
| hideText | false | | Controller whether or not show the dateText |string | date
| minDate | - | | Restricts the range of possible date values. |string | date
| maxDate | - | | Restricts the range of possible date values. |boolean
| disabled | false | | Controller whether or not disable the picker |boolean
| is24Hour | - | | Set the TimePicker is24Hour flag. The default value depend on format. Only work in Android |boolean
| allowFontScaling | true | | Set to false to disable font scaling for every text component |string
| placeholder | '' | | The placeholder show when this.props.date is falsy |function
| onDateChange | - | | This is called when the user confirm the picked date or time in the UI. The first and only argument is a date or time string representing the new date and time formatted by moment.js with the given format property. |function
| onOpenModal | - | | This is called when the DatePicker Modal open. |function
| onCloseModal | - | | This is called when the DatePicker Modal close |function
| onPressMask | - | | This is called when clicking the ios modal mask |function
| modalOnResponderTerminationRequest | - | | Set 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. |TouchableHighlight
| TouchableComponent | | Component | Replace the TouchableHighlight with a custom Component. For example : TouchableOpacity |String
| getDateStr | - | Function | A function to override how to format the date into a for display, receives a Date` instance
- Email - info@tulparyazilim.com.tr
- LinkedIn - Tulpar Yazılım
- Blog - Blog
---

⭐️ From Tulpar Yazılım