I am using "@mui/x-date-pickers": "^6.9.2",
for the showing datetime picket
Now i want to do some styling chages to the popup which helps to select date and time.
How can i do it
I tried
<MobileDateTimePicker
label="End DateTime"
inputRef={ref}
minDate={subDays(new Date(), 90)}
disableFuture
{...field}
sx={{
"& .MuiPickersToolbarText-root.Mui-selected": {
color: "#fff",
backgroundColor: "#e91e63",
fontWeight: "600",
WebkitTransition:
"background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
transition: "background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
borderRadius: "50%",
fontSize: "0.75rem",
width: "36px",
height: "36px",
display: "inline-flex",
alignItems: "center",
justifyContent: "center",
},
"& .MuiDateTimePickerToolbar-separator": {
display: "inline-flex",
alignItems: "center",
justifyContent: "center",
},
}}
/>
But its not able to do any changes to the dialog open
2
Answers
Changes are not enabled because elements with classes
MuiPickersToolbarText-root
andMuiDateTimePickerToolbar-separator
are not nested fromMobileDateTimePicker
in the DOM, they are in a portal dialog.You can do:
Source:
Material UI Documentation:
https://mui.com/x/api/date-pickers/mobile-date-time-picker/
You can use
slotProps
property ofMobileDateTimePicker
.And you can also use
minDate
andmaxDate
props to block clicking on months or years.For example: