我有要求,我希望我的日期选择器突出显示周末,即星期六和星期日。我一直在使用Material-Ui-datepicker https://material-ui-pickers.dev/demo/datepicker。我尝试了各种方法,但是没有用。请任何人可以帮助我吗?
答案 0 :(得分:1)
您可以使用renderDay
道具。它允许自定义任何一天。
这是如何更改随机日期显示的官方示例。基本上,您需要在周末更改外观。 https://material-ui-pickers.dev/demo/datepicker#customization
v3的功能示例
renderDay={(day, selected, dayComponent) => {
if (isWeekend(day)) {
return React.cloneElemnt(dayComponent, { className: 'your-css' })
}
return dayComponent
}
v4的功能示例
renderDay={(day, selected, DayProps) => {
if (isWeekend(day)) {
return <Day {...DayProps} className={clsx(DayProps.classname, 'your-css')} />
}
return <Day {...DayProps} />
}