React Calendar

Ultimate calendar for your React app.

README

npm downloads CI tested with jest

React-Calendar



Ultimate calendar for your React app.

- Pick days, months, years, or even decades
- Supports range selection
- Supports virtually any language
- No moment.js needed

tl;dr


- Install by executing npm install react-calendar or yarn add react-calendar.
- Import by adding import Calendar from 'react-calendar'.
- Use by adding ``. Use `onChange` prop for getting new values.

Demo


A minimal demo page can be found in sample directory.

Online demo is also available!

Before you continue


React-Calendar is under constant development. This documentation is written for React-Calendar 3.x branch. If you want to see documentation for other versions of React-Calendar, use dropdown on top of GitHub page to switch to an appropriate tag. Here are quick links to the newest docs from each branch:


Getting started


Compatibility


Your project needs to use React 16.3 or later.

React-Calendar uses modern web technologies. That's why it's so fast, lightweight and easy to style. This, however, comes at a cost of supporting only modern browsers.

Legacy browsers


If you need to support legacy browsers like Internet Explorer 10, you will need to use Intl.js or another Intl polyfill along with React-Calendar.

My locale isn't supported! What can I do?


If your locale isn't supported, you can use Intl.js or another Intl polyfill along with React-Calendar.

Installation


Add React-Calendar to your project by executing npm install react-calendar or yarn add react-calendar.

Usage


Here's an example of basic usage:

  1. ``` js
  2. import React, { useState } from 'react';
  3. import Calendar from 'react-calendar';

  4. function MyApp() {
  5.   const [value, onChange] = useState(new Date());

  6.   return (
  7.     <div>
  8.       <Calendar onChange={onChange} value={value} />
  9.     </div>
  10.   );
  11. }
  12. ```

Check the sample directory in this repository for a full working example. For more examples and more advanced use cases, check Recipes in React-Calendar Wiki.

Custom styling


If you want to use default React-Calendar styling to build upon it, you can import React-Calendar's styles by using:

  1. ``` js
  2. import 'react-calendar/dist/Calendar.css';
  3. ```

User guide


Calendar


Displays a complete, interactive calendar.

Props


PropDescriptionDefaultExample
------------
activeStartDateThe(today)`new
allowPartialRangeWhether`false``true`
calendarTypeTypeType`"ISO
classNameClassn/a
  • String:
defaultActiveStartDateThe(today)`new
defaultValueCalendarn/a
  • Date:
defaultViewDeterminesThe`"year"`
formatDayFunction(default`(locale,
formatLongDateFunction(default`(locale,
formatMonthFunction(default`(locale,
formatMonthYearFunction(default`(locale,
formatShortWeekdayFunction(default`(locale,
formatWeekdayFunction(default`(locale,
formatYearFunction(default`(locale,
goToRangeStartOnSelectWhether`true``false`
inputRefAn/a
  • Function:
localeLocaleUser's`"hu-HU"`
maxDateMaximumn/aDate:
maxDetailThe`"month"``"year"`
minDateMinimumn/aDate:
minDetailThe`"century"``"decade"`
navigationAriaLabel`aria-label`n/a`"Go
navigationAriaLive`aria-live``undefined``"polite"`
navigationLabelContent(default``
nextAriaLabel`aria-label`n/a`"Next"`
nextLabelContent`"›"`
  • String:
next2AriaLabel`aria-label`n/a`"Jump
next2LabelContent`"»"`
  • String:
onActiveStartDateChangeFunctionn/a`({
onChangeFunctionn/a`(value,
onViewChangeFunctionn/a`({
onClickDayFunctionn/a`(value,
onClickDecadeFunctionn/a`(value,
onClickMonthFunctionn/a`(value,
onClickWeekNumberFunctionn/a`(weekNumber,
onClickYearFunctionn/a`(value,
onDrillDownFunctionn/a`({
onDrillUpFunctionn/a`({
prevAriaLabel`aria-label`n/a`"Previous"`
prevLabelContent`"‹"`
  • String:
prev2AriaLabel`aria-label`n/a`"Jump
prev2LabelContent`"«"`
  • String:
returnValueWhich`"start"``"range"`
showDoubleViewWhether`false``true`
showFixedNumberOfWeeksWhether`false``true`
showNavigationWhether`true``false`
showNeighboringMonthWhether`true``false`
selectRangeWhether`false``true`
showWeekNumbersWhether`false``true`
tileClassNameClassn/a
  • String:
tileContentAllowsn/a
  • String:
tileDisabledPassn/a
  • Function:
valueCalendarn/a
  • Date:
viewDeterminesThe`"year"`

MonthView, YearView, DecadeView, CenturyView


Displays a given month, year, decade and a century, respectively.

Props


PropDescriptionDefaultExample
------------
activeStartDateThen/a`new
hoverThen/a`new
maxDateMaximumn/aDate:
minDateMinimumn/aDate:
onClickFunctionn/a`(value)
tileClassNameClassn/a
  • String:
tileContentAllowsn/a`({
valueCalendarn/a
  • Date:

Useful links



License


The MIT License.

Author


Wojciech Maj
kontakt@wojtekmaj.pl
https://wojtekmaj.pl

Thank you


Sponsors


Thank you to all our sponsors! Become a sponsor and get your image on our README on GitHub.


Backers


Thank you to all our backers! Become a backer and get your image on our README on GitHub.


Top Contributors


Thank you to all our contributors that helped on this project!

Top Contributors