npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2019 – Ryan Hefner

react-calendar

v2.19.2

Published

Ultimate calendar for your React app.

Downloads

257,523

Readme

npm downloads build dependencies dev dependencies 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 <Calendar />. Use onChange prop for getting new values.

Demo

Minimal demo page is included in sample directory.

Online demo is also available!

Getting started

Compatibility

Your project needs to use React 15.5 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.

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 React, { Component } from 'react';
import Calendar from 'react-calendar';

class MyApp extends Component {
  state = {
    date: new Date(),
  }

  onChange = date => this.setState({ date })

  render() {
    return (
      <div>
        <Calendar
          onChange={this.onChange}
          value={this.state.date}
        />
      </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 don't want to use default React-Calendar styling to build upon it, you can import React-Calendar by using import Calendar from 'react-calendar/dist/entry.nostyle'; instead.

User guide

Calendar

Displays a complete, interactive calendar.

Props

Prop nameDescriptionDefault valueExample values
activeStartDateThe beginning of a period that shall be displayed by default when no value is given.(today)new Date(2017, 0, 1)
calendarTypeType 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"
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"]
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 month and year in the top navigation section. 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. Can be used to use your own formatting function.(default formatter)(locale, date) => formatDate(date, 'dd')
localeLocale that should be used by the calendar. Can be any IETF language tag.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"
navigationLabelContent of a label rendered on calendar navigation bar.(default label)({ date, view, label }) => `Current view: ${view}, date: ${date.toLocaleDateString()}`
nextAriaLabelaria-label attribute of the "next" button on the navigation pane.n/a"Next"
nextLabelContent of the "next" button on the navigation pane."›"
  • String: "›"
  • React element: <NextIcon />
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."»"
  • String: "»"
  • React element: <DoubleNextIcon />
onActiveDateChangeFunction called when the user navigates from one view to another using previous/next button.n/a({ activeStartDate, 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) => alert('New date is: ', value)
onClickDayFunction called when the user clicks a day.n/a(value) => alert('Clicked day: ', value)
onClickDecadeFunction called when the user clicks a decade.n/a(value) => alert('Clicked decade: ', value)
onClickMonthFunction called when the user clicks a month.n/a(value) => alert('Clicked month: ', value)
onClickWeekNumberFunction called when the user clicks a week number.n/a(weekNumber, date) => alert('Clicked week: ', weekNumber, 'that starts on: ', date)
onClickYearFunction called when the user clicks a year.n/a(value) => 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)
prevAriaLabelaria-label attribute of the "previous" button on the navigation pane.n/a"Previous"
prevLabelContent of the "previous" button on the navigation pane."‹"
  • String: "‹"
  • React element: <PreviousIcon />
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."«"
  • String: "«"
  • React element: <DoublePreviousIcon />
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"
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
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
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
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: ({ 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: ({ 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
  • Function: ({activeStartDate, date, view }) => date.getDay() === 0
valueCalendar value.n/a
  • Date: new Date()
  • An array of dates: [new Date(2017, 0, 1), new Date(2017, 7, 1)]
    viewDetermines which calendar view shall be opened initially. Does not disable navigation. Can be "month", "year", "decade" or "century".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.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 ? 'saturday' : 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.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']

    License

    The MIT License.

    Author

    Wojciech Maj
    [email protected]
    http://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