I’m trying to set another color to the text in TimePicker when it is disabled, but with no success. Does anyone knows how to do change it using sx or slotProps? Here is my current code.
<TimePicker
disabled={true} // disabled here
ampm={false}
views={['hours', 'minutes', 'seconds']}
sx={{
backgroundColor: "#333335",
font: "white",
color: "#FFFF",
textDecoration: "bold",
input: {
color: "#FFFF",
fontSize: "1.4rem",
}
}}
slotProps={{
popper: {
sx: {
"& .MuiList-root": {
backgroundColor: "#333335",
},
"& .MuiMenuItem-root": {
"&.Mui-selected": {
backgroundColor: "#04395E",
color: "white"
},
color: "white"
},
},
},
}}
value={selectedTime}
onChange={(newTime: any) => setSelectedTime(newTime)}
timeSteps={{hours: 1, minutes: 1, seconds: 1}}
/>
2
Answers
The placeholder is styled using the
-webkit-text-fill-color
property:Demo.
If you don’t pass any value or defaultValue prop, the input element will be empty and show the placeholder text instead. The placeholder text is usually a light gray color.
WebkitTextFillColor
change only text color, not placeholder color. So you need to pass value to yourTimePicker
.You can try this:
You can see the whole example here.