freiksenet / react-calendar

A modular toolkit to build calendar-related things in React
http://freiksenet.github.io/react-calendar/
MIT License
249 stars 46 forks source link

How to add a className? #1

Closed parris closed 9 years ago

parris commented 9 years ago

Awesome library. Is there currently a way to add a class to a day or month or even override?

freiksenet commented 9 years ago

Thank you for your interest, I am sorry that the documentation is quite lacking. Note that react-calendar is in a very alpha stage, so the API is subject to change and there are currently some performance problems on redrawing that I will fix when I have time. And certainly some bugs.

react-calendar uses SuitCSS style (a variant of BEM) to make default class hierarchy, if you want to add a class that is separate from that hierarchy just pass classes prop to any component. classes is an object with keys as classes and values as boolean-like values (this will be probably changed to just passing array of classes in future API). If you want to add SuitCSS modifier classes (something like rc-Day--current), pass similar object via modifiers prop (again this will probably become an array in next version of API).

For example:

<Day date={moment()} classes={{foo: true}} modifiers={{bar: true}} />

will yield the following classes: "rc-Day rc-Day--bar foo".

parris commented 9 years ago

Oh cool! Yup, just what i was looking for. Thanks.