[![npm](https://img.shields.io/npm/v/react-calendar.svg)](https://www.npmjs.com/package/react-calendar) ![downloads](https://img.shields.io/npm/dt/react-calendar.svg) [![CI](https://github.com/wojtekmaj/react-calendar/workflows/CI/badge.svg)](https://github.com/wojtekmaj/react-calendar/actions) [![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/facebook/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](http://projects.wojtekmaj.pl/react-calendar/) 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: - [v2.x](https://github.com/wojtekmaj/react-calendar/blob/v2.x/README.md) ## 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](https://caniuse.com/#feat=internationalization). #### Legacy browsers If you need to support legacy browsers like Internet Explorer 10, you will need to use [Intl.js](https://github.com/andyearnshaw/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](https://github.com/andyearnshaw/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: ```js import React, { useState } from 'react'; import Calendar from 'react-calendar'; function MyApp() { const [value, onChange] = useState(new Date()); return (
); } ``` Check the [sample directory](https://github.com/wojtekmaj/react-calendar/tree/main/sample) in this repository for a full working example. For more examples and more advanced use cases, check [Recipes](https://github.com/wojtekmaj/react-calendar/wiki/Recipes) in [React-Calendar Wiki](https://github.com/wojtekmaj/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: ```js import 'react-calendar/dist/Calendar.css'; ``` ## User guide ### Calendar Displays a complete, interactive calendar. #### Props | Prop name | Description | Default value | Example values | | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | activeStartDate | The beginning of a period that shall be displayed. If you wish to use React-Calendar in an uncontrolled way, use `defaultActiveStartDate` instead. | (today) | `new Date(2017, 0, 1)` | | allowPartialRange | Whether to call onChange with only partial result given `selectRange` prop. | `false` | `true` | | calendarType | Type of calendar that should be used. Can be `"ISO 8601"`, `"US"`, `"Arabic"`, or `"Hebrew"`. Setting to `"US"` or `"Hebrew"` will change the first day of the week to Sunday. Setting to `"Arabic"` will change the first day of the week to Saturday. Setting to `"Arabic"` or `"Hebrew"` will make weekends appear on Friday to Saturday. | Type of calendar most commonly used in a given locale | `"ISO 8601"` | | className | Class name(s) that will be added along with `"react-calendar"` to the main React-Calendar `
` element. | n/a | | | defaultActiveStartDate | The beginning of a period that shall be displayed by default. If you wish to use React-Calendar in a controlled way, use `activeStartDate` instead. | (today) | `new Date(2017, 0, 1)` | | defaultValue | Calendar value that shall be selected initially. Can be either one value or an array of two values. If you wish to use React-Calendar in a controlled way, use `value` instead. | n/a |