Skip to content

Latest commit

 

History

History
150 lines (145 loc) · 4.4 KB

DatePicker.md

File metadata and controls

150 lines (145 loc) · 4.4 KB

date-picker-def-headref

Date Picker

Date Picker allows the user to select a date from a time range.

Preview ios date-picker-def-headref Preview android date-picker-def-headref

Syntax

{% codetabs name="React Native", type="js" -%} import React, { Component } from 'react'; import { Container, Header, Content, DatePicker, Text } from 'native-base'; export default class DatePickerExample extends Component { constructor(props) { super(props); this.state = { chosenDate: new Date() }; this.setDate = this.setDate.bind(this); } setDate(newDate) { this.setState({ chosenDate: newDate }); } render() { return (

<DatePicker defaultDate={new Date(2018, 4, 4)} minimumDate={new Date(2018, 1, 1)} maximumDate={new Date(2018, 12, 31)} locale={"en"} timeZoneOffsetInMinutes={undefined} modalTransparent={false} animationType={"fade"} androidMode={"default"} placeHolderText="Select date" {% raw %}textStyle={{ color: "green" }}{% endraw %} {% raw %}placeHolderTextStyle={{ color: "#d3d3d3" }}{% endraw %} onDateChange={this.setDate} disabled={false} /> Date: {this.state.chosenDate.toString().substr(4, 12)} ); } } {%- language name="Vue Native", type="vue" -%} {% raw %}Date: {{chosenDate.toString().substr(4, 12)}}{% endraw %}

<script> import React from "react"; export default { data: function() { return { defaultDate: new Date('2018-06-04'), minimumDate: new Date('2018-01-01'), maximumDate: new Date('2018-12-31'), chosenDate: new Date() }; }, methods: { setDate: function(newDate) { this.chosenDate = newDate; } } }; </script>

{%- endcodetabs %}

Configuration

Property Default Option Description
defaultDate - Date Object Sets default date in calendar
minimumDate - Date Object Sets minimum date that can be set in calendar
maximumDate - Date Object Sets maximum date that can be set in calendar
androidMode - string can take either of values 'default','calendar','spinner'
animationType - string can take either of values 'fade','slide','none'
disabled true boolean Prevent user from making selection of date
supportedOrientations - Portrait, Landscape, Landscape-left, Landscape-right Allows the modal to rotate to any of the specified orientations