-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[pickers] Allow to override the header of the DateCalendar
#6653
Comments
Thanks for the proposal. I think it takes part of a larger issue which is about being able to customize calendar header. We should be able to provide a slot for it, and to modify the format to replace month and year by only month for example. By the way, I'm wondering if it would not be easier to create your how calendar view. with rounded buttons. It would save you all the complexity of checking if days are disabled, the transition between months, and other internal logic since you only use days has toggle buttons. And it would avoid the following bug in your demo: Focus on a day, and press the key down multiple times. you will be able to switch months Another idea could be to export the calendar as a pure component |
Hi @alexfauquette, Thanks for pointing out the bug. Unfortunately I don't understand your proposition with "calendar view with rounded buttons". Could point me to the components you're referring to? Thanks, |
I thought that you could create your own calendar from scratch because the only interaction you need is the click on days, they do not interact all together |
@alexfauquette I'm looking forward for customized calendar header feature :) I figured out a way to disable pageUp / pageDown after focus: //Disable pageUp / pageDown navigation inside given month
shouldDisableDate={(date) => !dayjs(calendarView).isSame(dayjs(date), "month") Another thing I noticed is that I cannot set sx property for StaticDatePicker https://codesandbox.io/s/year-view-business-days-sk5h3z?file=/demo.tsx That's why I used styled-component: const CustomizedStaticDatePicker = styled(
(props: StaticDatePickerProps<any, any>) => <StaticDatePicker {...props} />
)`
.MuiPickersCalendarHeader-labelContainer {
cursor: default;
}
`; I looked into source and found, so maybe sx should work? /**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])),
PropTypes.func,
PropTypes.object,
]), Any toughs on this one? |
Instead of About const CustomizedStaticDatePicker = styled(StaticDatePicker)`
.MuiPickersCalendarHeader-labelContainer {
cursor: default;
}
`; About the |
I tried shouldDisableMonth, but it doesn't run: shouldDisableMonth={(date) => {
//Does not run
console.info(date);
return true;
}} Regarding sx prop I have the latest "@mui/x-date-pickers": "^5.0.6", and I did: npm un -D @mui/x-date-pickers and I still see on my localhost: |
All the |
My bad, I thought you were on the |
DateCalendar
DateCalendar
DateCalendar
Hi everyone ! I'm using DatePicker from MUI X and I have a special use case where I only need to set periods of time (and range picker is not what we need) with a picker for the begin date and another one for the end date. In this use case, the year is fully abstract and in order to not confuse the user, I need to hide the year in the popover of the DateCalendar. I know @flaviendelangle has added a new slot for accessing CalendarHeader, but currently I didn't find a way to access the label prop inside the CalendarHeader. The only thing I can do is replace CalendarHeader by a custom component or just hide the year in CSS. Is it possible to access it or is it planned in the future ? |
Hello @enckao The way we create the label is by calling |
I'll give it a try, thanks a lot for the advice ! |
Duplicates
Latest version
Summary 💡
I would like to format month label to remove year
Expected
Examples 🌈
I created an example of using StaticDatePicker & PickersDay:
https://codesandbox.io/s/year-view-business-days-sk5h3z?file=/demo.tsx
Maybe it could be added as a demo here:
https://mui.com/x/api/date-pickers/static-date-picker/
https://mui.com/x/api/date-pickers/pickers-day/
Motivation 🔦
The purpose is to have a year view and be able to mark holidays during a given year for example for a financial institution.
Order ID 💳 (optional)
No response
The text was updated successfully, but these errors were encountered: