-
-
Notifications
You must be signed in to change notification settings - Fork 766
Closed
Milestone
Description
API proposal
- a new prop
classNamesreceiving an object containing the class names for the single elements, such ascontainer,day,caption, ecc. Must be validated via PropTypes. - modifiers passed to the
modifiersprop must return a string instead of a boolean. This string will be added to the day's cell class name. For CSS modules, it should be the imported class name.- if the returned value is falsy, no class name will be added to the day cell.
Note that this change would work also for any class names, e.g. people adopting other convention than BEM can specify their own class names.
Example using CSS Modules
import classNames from './daypicker.css';
import { todayClassName, weekendClassName } from './daypicker-modifiers.css';
import { isToday, isWeekend } from './myDateUtils';
const modifiers = {
today: day => {
if (isToday(day)) {
return todayClassName;
}
return '';
},
weekend: day => {
if (isWeekend(day)) {
return weekendClassName;
}
return '';
},
};
function MyComponent() {
return (
<div>
<DayPicker classNames={classNames} modifiers={modifiers} />
</div>
);
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels