react-calendar vs react-datepicker vs react-datetime vs react-native-date-picker vs react-native-datepicker vs react-native-modal-datetime-picker
React Date and Time Picker Libraries
react-calendarreact-datepickerreact-datetimereact-native-date-pickerreact-native-datepickerreact-native-modal-datetime-pickerSimilar Packages:

React Date and Time Picker Libraries

These libraries provide various components for selecting dates and times in React applications. They cater to different use cases, including web and mobile applications, and offer unique features for user interaction, customization, and localization. Choosing the right library depends on the specific requirements of your project, such as the need for mobile compatibility, customization options, and user experience.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
react-calendar03,786271 kB3816 days agoMIT
react-datepicker08,3664.5 MB664 months agoMIT
react-datetime02,007291 kB182a year agoMIT
react-native-date-picker02,4953.97 MB70a year agoMIT
react-native-datepicker02,113-2858 years agoMIT
react-native-modal-datetime-picker03,05043.9 kB582 years agoMIT

Feature Comparison: react-calendar vs react-datepicker vs react-datetime vs react-native-date-picker vs react-native-datepicker vs react-native-modal-datetime-picker

User Interface

  • react-calendar:

    react-calendar offers a clean and straightforward calendar interface, allowing users to navigate through months and select dates easily. It is designed to be visually appealing while maintaining simplicity, making it user-friendly for all ages.

  • react-datepicker:

    react-datepicker features a dropdown interface that allows users to select dates and times conveniently. It includes a calendar view and time selection, making it versatile for various input scenarios and enhancing user interaction.

  • react-datetime:

    react-datetime combines both date and time selection in a single interface, providing a seamless user experience. Its design allows users to switch between date and time views easily, catering to applications that require both inputs.

  • react-native-date-picker:

    react-native-date-picker provides a native mobile interface that aligns with iOS and Android design principles. It offers a smooth and responsive experience, ensuring that users feel comfortable interacting with the date picker on mobile devices.

  • react-native-datepicker:

    react-native-datepicker presents a simple and intuitive interface for date selection in mobile applications. It is designed to be easy to use, ensuring that users can quickly select dates without confusion.

  • react-native-modal-datetime-picker:

    react-native-modal-datetime-picker enhances the user interface by presenting the date and time picker in a modal. This approach minimizes distractions and focuses user attention on the selection process, improving overall usability.

Customization

  • react-calendar:

    react-calendar allows for extensive customization options, enabling developers to style the calendar according to their application's theme. You can easily modify colors, fonts, and layouts to match your design requirements.

  • react-datepicker:

    react-datepicker offers a variety of props for customization, including the ability to format dates, control the display of the calendar, and style components. This flexibility makes it suitable for applications with specific design needs.

  • react-datetime:

    react-datetime provides customization options for both date and time formats, allowing developers to tailor the component to fit their application's requirements. You can also customize the appearance and behavior of the picker.

  • react-native-date-picker:

    react-native-date-picker is designed to be easily customizable, allowing developers to change styles and properties to fit the app's design. It supports various modes, such as date, time, or datetime, enhancing its versatility.

  • react-native-datepicker:

    react-native-datepicker allows for basic customization, including date formats and styles. While it may not be as flexible as others, it still provides enough options for most standard use cases.

  • react-native-modal-datetime-picker:

    react-native-modal-datetime-picker offers customization for the modal presentation, including styles and animations. This allows developers to create a unique user experience that aligns with their app's design.

Localization

  • react-calendar:

    react-calendar supports localization, allowing developers to present dates in various formats based on user preferences or regional settings. This feature is essential for applications targeting a global audience.

  • react-datepicker:

    react-datepicker includes built-in localization support, enabling developers to easily adapt the date picker to different languages and formats. This makes it suitable for international applications.

  • react-datetime:

    react-datetime supports localization, allowing developers to format dates and times according to user preferences. This feature enhances usability for users from different regions.

  • react-native-date-picker:

    react-native-date-picker supports localization, ensuring that date and time formats align with local conventions. This is crucial for mobile applications that cater to diverse user bases.

  • react-native-datepicker:

    react-native-datepicker provides basic localization support, allowing developers to format dates according to user preferences. While not as extensive as others, it still meets the needs of many applications.

  • react-native-modal-datetime-picker:

    react-native-modal-datetime-picker supports localization, allowing developers to present date and time formats that are familiar to users in different regions, enhancing the overall user experience.

Mobile Compatibility

  • react-calendar:

    react-calendar is primarily designed for web applications and may not provide the best user experience on mobile devices. It is best suited for desktop applications where a full calendar view is beneficial.

  • react-datepicker:

    react-datepicker is also primarily for web applications and may not be optimized for mobile use. It is best used in scenarios where desktop users are the primary audience.

  • react-datetime:

    react-datetime is designed for web applications and may not offer the best mobile experience. It is ideal for projects where desktop usage is predominant.

  • react-native-date-picker:

    react-native-date-picker is specifically built for React Native applications, ensuring a native look and feel on mobile devices. It is the best choice for mobile-first applications requiring date selection.

  • react-native-datepicker:

    react-native-datepicker is tailored for mobile applications, providing a simple and effective date selection interface. It is suitable for projects focused on mobile user experience.

  • react-native-modal-datetime-picker:

    react-native-modal-datetime-picker is optimized for mobile applications, providing a modal interface that enhances usability on mobile devices. It is ideal for apps that prioritize a clean and focused user experience.

Integration

  • react-calendar:

    react-calendar can be easily integrated into any React application, making it a versatile choice for developers looking for a straightforward calendar component without complex dependencies.

  • react-datepicker:

    react-datepicker integrates well with forms and other UI components, making it a suitable choice for applications that require date input alongside other form elements.

  • react-datetime:

    react-datetime can be integrated seamlessly into forms and other components, offering a consistent user experience across the application. It is ideal for projects that require both date and time inputs.

  • react-native-date-picker:

    react-native-date-picker is designed for easy integration into React Native applications, ensuring that developers can quickly implement date selection features without extensive setup.

  • react-native-datepicker:

    react-native-datepicker is straightforward to integrate into React Native applications, providing a simple solution for date selection without complex configurations.

  • react-native-modal-datetime-picker:

    react-native-modal-datetime-picker is easy to integrate into React Native applications, allowing developers to implement a modal date and time picker with minimal effort.

How to Choose: react-calendar vs react-datepicker vs react-datetime vs react-native-date-picker vs react-native-datepicker vs react-native-modal-datetime-picker

  • react-calendar:

    Choose react-calendar if you need a simple and customizable calendar component for selecting dates. It is lightweight and easy to integrate into any React application, making it ideal for projects that require a straightforward date selection without complex features.

  • react-datepicker:

    Select react-datepicker for a more feature-rich date picker that supports date ranges, time selection, and localization. It is suitable for applications that require a robust date input with a user-friendly interface and extensive customization options.

  • react-datetime:

    Opt for react-datetime if you need a versatile component that combines both date and time selection. It is ideal for applications that require users to select both elements simultaneously, providing a seamless experience for datetime inputs.

  • react-native-date-picker:

    Use react-native-date-picker for mobile applications built with React Native. It offers a native look and feel, making it perfect for mobile apps that require a date and time selection interface that aligns with platform-specific design guidelines.

  • react-native-datepicker:

    Choose react-native-datepicker if you want a simple and customizable date picker for React Native applications. It provides a straightforward implementation and is suitable for projects that do not require extensive features but still need a reliable date selection component.

  • react-native-modal-datetime-picker:

    Select react-native-modal-datetime-picker for a modal-based date and time picker in React Native applications. It enhances user experience by presenting the picker in a modal, making it ideal for apps that prioritize a clean and focused interface.

README for react-calendar

npm downloads CI

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 <Calendar />. 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 4.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.8 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.

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:

import { useState } from 'react';
import Calendar from 'react-calendar';

type ValuePiece = Date | null;

type Value = ValuePiece | [ValuePiece, ValuePiece];

function MyApp() {
  const [value, onChange] = useState<Value>(new Date());

  return (
    <div>
      <Calendar onChange={onChange} value={value} />
    </div>
  );
}

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:

import 'react-calendar/dist/Calendar.css';

User guide

Calendar

Displays a complete, interactive calendar.

Props

Prop nameDescriptionDefault valueExample values
activeStartDateThe 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)
allowPartialRangeWhether to call onChange with only partial result given selectRange prop.falsetrue
calendarTypeType of calendar that should be used. Can be 'gregory, 'hebrew', 'islamic', 'iso8601'. Setting to "gregory" or "hebrew" will change the first day of the week to Sunday. Setting to "islamic" will change the first day of the week to Saturday. Setting to "islamic" or "hebrew" will make weekends appear on Friday to Saturday.Type of calendar most commonly used in a given locale'iso8601'
classNameClass name(s) that will be added along with "react-calendar" to the main react-calendar <div> element.n/a
  • String: "class1 class2"
  • Array of strings: ["class1", "class2 class3"]
data-testidThe test ID used for testing purposes.n/a'calendar'
defaultActiveStartDateThe 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)
defaultValueCalendar 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
  • Date: new Date()
  • An array of dates: [new Date(2017, 0, 1), new Date(2017, 7, 1)]
defaultViewDetermines which calendar view shall be opened initially. Does not disable navigation. Can be "month", "year", "decade" or "century". If you wish to use react-calendar in a controlled way, use view instead.The most detailed view allowed"year"
formatDayFunction called to override default formatting of day tile labels. Can be used to use your own formatting function.(default formatter)(locale, date) => formatDate(date, 'd')
formatLongDateFunction called to override default formatting of day tile abbr labels. Can be used to use your own formatting function.(default formatter)(locale, date) => formatDate(date, 'dd MMM YYYY')
formatMonthFunction called to override default formatting of month names. Can be used to use your own formatting function.(default formatter)(locale, date) => formatDate(date, 'MMM')
formatMonthYearFunction called to override default formatting of months and years. Can be used to use your own formatting function.(default formatter)(locale, date) => formatDate(date, 'MMMM YYYY')
formatShortWeekdayFunction called to override default formatting of weekday names (shortened). Can be used to use your own formatting function.(default formatter)(locale, date) => formatDate(date, 'dd')
formatWeekdayFunction called to override default formatting of weekday names. Can be used to use your own formatting function.(default formatter)(locale, date) => formatDate(date, 'dd')
formatYearFunction called to override default formatting of year in the top navigation section. Can be used to use your own formatting function.(default formatter)(locale, date) => formatDate(date, 'YYYY')
goToRangeStartOnSelectWhether to go to the beginning of the range when selecting the end of the range.truefalse
inputRefA prop that behaves like ref, but it's passed to main <div> rendered by <Calendar> component.n/a
  • Function:
    (ref) => { this.myCalendar = ref; }
  • Ref created using createRef:
    this.ref = createRef();
    …
    inputRef={this.ref}
  • Ref created using useRef:
    const ref = useRef();
    …
    inputRef={ref}
localeLocale that should be used by the calendar. Can be any IETF language tag. Note: When using SSR, setting this prop may help resolving hydration errors caused by locale mismatch between server and client.Server locale/User's browser settings"hu-HU"
maxDateMaximum date that the user can select. Periods partially overlapped by maxDate will also be selectable, although react-calendar will ensure that no later date is selected.n/aDate: new Date()
maxDetailThe most detailed view that the user shall see. View defined here also becomes the one on which clicking an item will select a date and pass it to onChange. Can be "month", "year", "decade" or "century"."month""year"
minDateMinimum date that the user can select. Periods partially overlapped by minDate will also be selectable, although react-calendar will ensure that no earlier date is selected.n/aDate: new Date()
minDetailThe least detailed view that the user shall see. Can be "month", "year", "decade" or "century"."century""decade"
navigationAriaLabelaria-label attribute of a label rendered on calendar navigation bar.n/a"Go up"
navigationAriaLivearia-live attribute of a label rendered on calendar navigation bar.undefined"polite"
navigationLabelContent of a label rendered on calendar navigation bar.(default label)({ date, label, locale, view }) => alert(`Current view: ${view}, date: ${date.toLocaleDateString(locale)}`)
next2AriaLabelaria-label attribute of the "next on higher level" button on the navigation pane.n/a"Jump forwards"
next2LabelContent of the "next on higher level" button on the navigation pane. Setting the value explicitly to null will hide the icon."Ā»"
  • String: "Ā»"
  • React element: <DoubleNextIcon />
nextAriaLabelaria-label attribute of the "next" button on the navigation pane.n/a"Next"
nextLabelContent of the "next" button on the navigation pane. Setting the value explicitly to null will hide the icon."›"
  • String: "›"
  • React element: <NextIcon />
onActiveStartDateChangeFunction called when the user navigates from one view to another using previous/next button. Note that this function will not be called when e.g. drilling up from January 2021 to 2021 or drilling down the other way around.
action signifies the reason for active start date change and can be one of the following values: "prev", "prev2", "next", "next2", "drillUp", "drillDown", "onChange".
n/a({ action, activeStartDate, value, view }) => alert('Changed view to: ', activeStartDate, view)
onChangeFunction called when the user clicks an item (day on month view, month on year view and so on) on the most detailed view available.n/a(value, event) => alert('New date is: ', value)
onClickDayFunction called when the user clicks a day.n/a(value, event) => alert('Clicked day: ', value)
onClickDecadeFunction called when the user clicks a decade.n/a(value, event) => alert('Clicked decade: ', value)
onClickMonthFunction called when the user clicks a month.n/a(value, event) => alert('Clicked month: ', value)
onClickWeekNumberFunction called when the user clicks a week number.n/a(weekNumber, date, event) => alert('Clicked week: ', weekNumber, 'that starts on: ', date)
onClickYearFunction called when the user clicks a year.n/a(value, event) => alert('Clicked year: ', value)
onDrillDownFunction called when the user drills down by clicking a tile.n/a({ activeStartDate, view }) => alert('Drilled down to: ', activeStartDate, view)
onDrillUpFunction called when the user drills up by clicking drill up button.n/a({ activeStartDate, view }) => alert('Drilled up to: ', activeStartDate, view)
onViewChangeFunction called when the user navigates from one view to another using drill up button or by clicking a tile.
action signifies the reason for view change and can be one of the following values: "prev", "prev2", "next", "next2", "drillUp", "drillDown", "onChange".
n/a({ action, activeStartDate, value, view }) => alert('New view is: ', view)
prev2AriaLabelaria-label attribute of the "previous on higher level" button on the navigation pane.n/a"Jump backwards"
prev2LabelContent of the "previous on higher level" button on the navigation pane. Setting the value explicitly to null will hide the icon."Ā«"
  • String: "Ā«"
  • React element: <DoublePreviousIcon />
prevAriaLabelaria-label attribute of the "previous" button on the navigation pane.n/a"Previous"
prevLabelContent of the "previous" button on the navigation pane. Setting the value explicitly to null will hide the icon."‹"
  • String: "‹"
  • React element: <PreviousIcon />
returnValueWhich dates shall be passed by the calendar to the onChange function and onClick{Period} functions. Can be "start", "end" or "range". The latter will cause an array with start and end values to be passed."start""range"
selectRangeWhether the user shall select two dates forming a range instead of just one. Note: This feature will make react-calendar return array with two dates regardless of returnValue setting.falsetrue
showDoubleViewWhether to show two months/years/… at a time instead of one. Defaults showFixedNumberOfWeeks prop to be true.falsetrue
showFixedNumberOfWeeksWhether to always show fixed number of weeks (6). Forces showNeighboringMonth prop to be true.falsetrue
showNavigationWhether a navigation bar with arrows and title shall be rendered.truefalse
showNeighboringCenturyWhether decades from next century shall be rendered to fill the entire last row in.falsetrue
showNeighboringDecadeWhether years from next decade shall be rendered to fill the entire last row in.falsetrue
showNeighboringMonthWhether days from previous or next month shall be rendered if the month doesn't start on the first day of the week or doesn't end on the last day of the week, respectively.truefalse
showWeekNumbersWhether week numbers shall be shown at the left of MonthView or not.falsetrue
tileClassNameClass name(s) that will be applied to a given calendar item (day on month view, month on year view and so on).n/a
  • String: "class1 class2"
  • Array of strings: ["class1", "class2 class3"]
  • Function: ({ activeStartDate, date, view }) => view === 'month' && date.getDay() === 3 ? 'wednesday' : null
tileContentAllows to render custom content within a given calendar item (day on month view, month on year view and so on).n/a
  • String: "Sample"
  • React element: <TileContent />
  • Function: ({ activeStartDate, date, view }) => view === 'month' && date.getDay() === 0 ? <p>It's Sunday!</p> : null
tileDisabledPass a function to determine if a certain day should be displayed as disabled.n/a({ activeStartDate, date, view }) => date.getDay() === 0
valueCalendar value. Can be either one value or an array of two values. If you wish to use react-calendar in an uncontrolled way, use defaultValue instead.n/a
  • Date: new Date()
  • String: 2017-01-01
  • An array of dates: [new Date(2017, 0, 1), new Date(2017, 7, 1)]
  • An array of strings: ['2017-01-01', '2017-08-01']
viewDetermines which calendar view shall be opened. Does not disable navigation. Can be "month", "year", "decade" or "century". If you wish to use react-calendar in an uncontrolled way, use defaultView instead.The most detailed view allowed"year"

MonthView, YearView, DecadeView, CenturyView

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

Props

Prop nameDescriptionDefault valueExample values
activeStartDateThe beginning of a period that shall be displayed.n/anew Date(2017, 0, 1)
hoverThe date over which the user is hovering. Used only when selectRange is enabled, to render a ā€œWIPā€ range when the user is selecting range.n/anew Date(2017, 0, 1)
maxDateMaximum date that the user can select. Periods partially overlapped by maxDate will also be selectable, although react-calendar will ensure that no later date is selected.n/aDate: new Date()
minDateMinimum date that the user can select. Periods partially overlapped by minDate will also be selectable, although react-calendar will ensure that no earlier date is selected.n/aDate: new Date()
onClickFunction called when the user clicks an item (day on month view, month on year view and so on).n/a(value) => alert('New date is: ', value)
tileClassNameClass name(s) that will be applied to a given calendar item (day on month view, month on year view and so on).n/a
  • String: "class1 class2"
  • Array of strings: ["class1", "class2 class3"]
  • Function: ({ date, view }) => view === 'month' && date.getDay() === 3 ? 'wednesday' : null
tileContentAllows to render custom content within a given item (day on month view, month on year view and so on). Note: For tiles with custom content you might want to set fixed height of react-calendar__tile to ensure consistent layout.n/a({ date, view }) => view === 'month' && date.getDay() === 0 ? <p>It's Sunday!</p> : null
valueCalendar value. Can be either one value or an array of two values.n/a
  • Date: new Date()
  • An array of dates: [new Date(2017, 0, 1), new Date(2017, 7, 1)]
  • String: 2017-01-01
  • An array of strings: ['2017-01-01', '2017-08-01']

Useful links

License

The MIT License.

Author

Wojciech Maj Wojciech Maj

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