All Projects β†’ Naxulanth β†’ react-native-daterange-picker

Naxulanth / react-native-daterange-picker

Licence: MIT license
A React Native component for picking date ranges or single dates.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to react-native-daterange-picker

Vuetify Daterange Picker
The missing date range picker for Vuetify JS you have been looking for.
Stars: ✭ 192 (+123.26%)
Mutual labels:  datepicker, range, moment, daterange
Ion2 Calendar
πŸ“… A date picker components for ionic2 /ionic3 / ionic4
Stars: ✭ 537 (+524.42%)
Mutual labels:  calendar, datepicker, range, daterange
React Datepicker
πŸ“… React DatePicker Library (Flexible, Reusable)
Stars: ✭ 165 (+91.86%)
Mutual labels:  calendar, datepicker, moment
Angular Bootstrap Datetimepicker
Native Angular date/time picker component styled by Twitter Bootstrap
Stars: ✭ 1,289 (+1398.84%)
Mutual labels:  datepicker, moment, daterange
Calendarview
A highly customizable calendar library for Android, powered by RecyclerView.
Stars: ✭ 2,862 (+3227.91%)
Mutual labels:  calendar, datepicker, daterange
React Native Dates
React Native date / daterange picker and calendar
Stars: ✭ 145 (+68.6%)
Mutual labels:  calendar, datepicker, daterange
Lightpick
(deprecated) Check out the new date picker Litepicker
Stars: ✭ 204 (+137.21%)
Mutual labels:  datepicker, range, daterange
Vue Functional Calendar
Vue.js Functional Calendar | Component/Package
Stars: ✭ 314 (+265.12%)
Mutual labels:  calendar, datepicker, daterange
React Infinite Calendar
✨ Infinite scrolling date-picker built with React, with localization, range selection, themes, keyboard support, and more.
Stars: ✭ 3,828 (+4351.16%)
Mutual labels:  calendar, datepicker, range
Angular Moment Picker
Angular Moment Picker is an AngularJS directive for date and time picker using Moment.js.
Stars: ✭ 536 (+523.26%)
Mutual labels:  calendar, datepicker, moment
Vue Ctk Date Time Picker
VueJS component to select dates & time, including a range mode
Stars: ✭ 707 (+722.09%)
Mutual labels:  calendar, datepicker, range
Period
PHP's time range API
Stars: ✭ 616 (+616.28%)
Mutual labels:  calendar, range, daterange
Pg Calendar
πŸ“† beautiful and eidetic date picker
Stars: ✭ 109 (+26.74%)
Mutual labels:  calendar, datepicker, moment
React Calendar
React.js Calendar Component (npm install react-calendar-component) πŸ“…
Stars: ✭ 142 (+65.12%)
Mutual labels:  calendar, datepicker
React Input Calendar
Stars: ✭ 138 (+60.47%)
Mutual labels:  calendar, moment
Moment Hijri
A Hijri calendar (Based on Umm al-Qura calculations) plugin for moment.js
Stars: ✭ 144 (+67.44%)
Mutual labels:  calendar, moment
Calendar
πŸ“† calendar ζ—₯εŽ†
Stars: ✭ 119 (+38.37%)
Mutual labels:  calendar, datepicker
Things Calendar
Simple but elegant datepicker for the web β€” inspired by Things for mac
Stars: ✭ 165 (+91.86%)
Mutual labels:  calendar, datepicker
React Numpad
A numpad for number, date and time, built with and for React.
Stars: ✭ 117 (+36.05%)
Mutual labels:  calendar, datepicker
React Datepicker2
react datepicker component.(include persian jalaali calendar)
Stars: ✭ 191 (+122.09%)
Mutual labels:  calendar, datepicker

react-native-daterange-picker

A React Native component for picking date ranges or single dates.

  • Completely customizable
  • Uses Moment.js for handling dates

Installation

yarn add react-native-daterange-picker

or

npm install --save react-native-daterange-picker

Usage

Date range

import React from "react";
import { StyleSheet, View, Text } from "react-native";
import moment from "moment";
import DateRangePicker from "react-native-daterange-picker";

export default class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      startDate: null,
      endDate: null,
      displayedDate: moment(),
    };
  }

  setDates = (dates) => {
    this.setState({
      ...dates,
    });
  };

  render() {
    const { startDate, endDate, displayedDate } = this.state;
    return (
      <View style={styles.container}>
        <DateRangePicker
          onChange={this.setDates}
          endDate={endDate}
          startDate={startDate}
          displayedDate={displayedDate}
          range
        >
          <Text>Click me!</Text>
        </DateRangePicker>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center",
  },
});

Single date

Use the date prop instead of the startDate and endDate props.

import React from "react";
import { StyleSheet, View, Text } from "react-native";
import moment from "moment";
import DateRangePicker from "react-native-daterange-picker";

export default class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      date: null,
      displayedDate: moment(),
    };
  }

  setDates = (dates) => {
    this.setState({
      ...dates,
    });
  };

  render() {
    const { date, displayedDate } = this.state;
    return (
      <View style={styles.container}>
        <DateRangePicker
          onChange={this.setDates}
          date={date}
          displayedDate={displayedDate}
        >
          <Text>Click me!</Text>
        </DateRangePicker>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center",
  },
});

Minimum and maximum allowed dates

Use the minDate and maxDate props to disable the dates that aren't allowed.

import React from "react";
import { StyleSheet, View, Text } from "react-native";
import moment from "moment";
import DateRangePicker from "react-native-daterange-picker";

export default class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      startDate: null,
      endDate: null,
      displayedDate: moment(),
      minDate: moment().set("date", 17),
      maxDate: moment().set("date", 20),
    };
  }

  setDates = (dates) => {
    this.setState({
      ...dates,
    });
  };

  render() {
    const { startDate, endDate, displayedDate, minDate, maxDate } = this.state;
    return (
      <View style={styles.container}>
        <DateRangePicker
          onChange={this.setDates}
          startDate={startDate}
          endDate={endDate}
          minDate={minDate}
          maxDate={maxDate}
          range
          displayedDate={displayedDate}
        >
          <Text>Click me!</Text>
        </DateRangePicker>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center",
  },
});

Setting locale

Simply pass your custom Moment object with locale attached to it as a prop.

import React from "react";
import { StyleSheet, View, Text } from "react-native";
import DateRangePicker from "react-native-daterange-picker";

import moment from "moment/min/moment-with-locales";
moment.locale("en");

export default class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      startDate: null,
      endDate: null,
      displayedDate: moment(),
    };
  }

  setDates = (dates) => {
    this.setState({
      ...dates,
    });
  };

  render() {
    const { startDate, endDate, displayedDate } = this.state;
    return (
      <View style={styles.container}>
        <DateRangePicker
          onChange={this.setDates}
          endDate={endDate}
          startDate={startDate}
          displayedDate={displayedDate}
          range
          moment={moment}
        >
          <Text>Click me!</Text>
        </DateRangePicker>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center",
  },
});

Options

Property type required? defaultValue Description
open boolean no Prop to control calendar visibility state. Passing this prop will disable the default function for toggling visibility off/on by clicking the backdrop/click me button.
onChange function yes Date change callback function.
startDate Moment yes (if range) Value of the picked start date.
endDate Moment yes (if range) Value of the picked end date.
date Moment yes (if no range) Value of the picked single date.
displayedDate Moment yes The date (year/month) which is being displayed on the picker.
minDate Moment no The minimum allowed date for the picker.
maxDate Moment no The maximum allowed date for the picker.
range boolean no false Allows you to pick between range and single date selection.
presetButtons boolean no false Enables preset buttons (Today / This Week / This Month)
dayHeaders boolean no true Allows you to enable/disable day headers.
backdropStyle Object no Styling for the backdrop of the picker.
containerStyle Object no Styling for the picker container.
headerStyle Object no Styling for header area.
headerTextStyle Object no Styling for header text.
dayStyle Object no Styling for a single day element.
dayTextStyle Object no Styling for the text of a single day element.
selectedStyle Object no Styling for selected day element(s).
selectedTextStyle Object no Styling for the text of selected day element(s).
dayHeaderStyle Object no Styling for selected day header element(s).
dayHeaderTextStyle Object no Styling for the text of day header element(s).
disabledStyle Object no Styling for disabled day element(s).
buttonStyle Object no Styling for the preset button(s).
buttonTextStyle Object no Styling for the text of preset button(s).
buttonContainerStyle Object no Styling for the preset button container.
monthPrevButton Node no Icon for previous button.
monthNextButton Node no Icon for next button.
monthButtonsStyle Object no Styling for month prev/next buttons.
moment Moment no Custom Moment object, useful for setting custom locale.

Questions & Suggestions

Feel free to contact me at [email protected] for your questions and suggestions.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].