2.3.0 • Published 4 years ago

react-datepicker-clean v2.3.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

React DatePicker

A simple and configurable datepicker made for React, free from any dependencies other than React.

Installation

Install it from npm and include it in your React build process (using Webpack, Browserify, etc):

npm install --save react-datepicker-clean

Note that React is needed in the project for this component to work and must be installed separately since it is not included in the package.

Usage

Most basic usage:

import React from "react";
import DatePicker from "react-datepicker-clean";

class Example extends React.Component {
  constructor(props) {
    this.state = {
      dates: []
    };
  }

  handleChange = dates => {
    this.setState({ dates });
  };

  render() {
    return (
      <DatePicker
        onDateClick={this.handleChange}
      />
    );
  }
}

Properties

This datepicker has a number of properties that can be used

Mandatory properties:

nametypedescription
onDateClickFunctionFunction to use when user clicks a date. Must take array of dates as argument.

Optional properties:

nametypedefault valuedescription
weekStartnumber<0 | 1 | 2 | 3 | 4 | 5 | 6>0Indicates which day is the first day of the week. 0 is Sunday, 6 is Saturday.
weekHolidaynumber<-1 | 0 | 1 | 2 | 3 | 4 | 5 | 60Indicates which date that should be designated weekly holiday (default red number instead of black). 0 is Sunday, 6 is Saturday. Set to -1 to disable this option.
showWeekNumberbooleantrueSet to false to hide week numbers.
multiChoicebooleanfalseSet to true if the user should be able to choose more than one date.
multiSpanbooleanfalseSet to true to make the choose a span of dates instead of multiple single dates. Disabled if multiChoice is set ti false.
allowBeforebooleanfalseSet to true if the user should be allowed to choose dates before the current date.
chosenDatesArray<Date | string | number>[]Any dates that should be chosen already. Can use same state element array that is updated in onDateClick. Elements can be Date object, ISO-8601 date string, UNIX timestamp or an array containing two dates. If the element is an array of two dates, all dates between (and including) the two dates will be marked.
blockedDatesArray<Date | string | number>[]Any dates that should be blocked from selecting. Elements can be Date object, ISO-8601 date string, UNIX timestamp or an array containing two dates. If the element is an array of two dates, all dates between (and including) the two dates will be marked.
holidayDatesArray<Date | string | number>[]Any holidays that should be marked as holiday (default red number instead of black). Elements can be Date object, ISO-8601 date string, UNIX timestamp or an array containing two dates. If the element is an array of two dates, all dates between (and including) the two dates will be marked.
yearsDiffnumber100How many years should be visible in years list (before if allowBefore is set to true and) after the current year.
localestring'en'Locale to use. List of available locales can be found here. Use the value in the "Code" column.

ToDo:

  • Add custom styling properties.
2.3.0

4 years ago

2.2.2

4 years ago

2.2.1

4 years ago

2.2.0

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago