Currently, I am attempting to customize the appearance of the KeyboardDatePicker
component including board color, size, font, and padding. However, none of the methods I have tried seem to be effective. Here is what I have attempted so far:
1 . Utilizing useStyles :
const useStyles = (params: any) =>
makeStyles(() =>
createStyles({
componentStyle: {
width: params.width ? params.width : 'auto',
color: params.color ? params.color : 'inherit',
verticalAlign: 'middle',
fontSize: '12px',
border: 'solid 2px #0070D8',
},
})
);
Unfortunately, this method does not override the default styles and a border still appears on the existing KeyboardDatePicker
, with no change in size.
2 . Implementing Theme provider, which successfully overrides the calendar theme but not the date box within the KeyboardDatePicker
.
<ThemeProvider theme={theme}>
3 . Adding inline styles directly into KeyboardDatePicker seems to be the only approach that works:
style={{width:"246px",height:"44px"}}
If you have any suggestions on how to properly modify the styles of the KeyboardDatePicker
component without using the style={} approach, please let me know. It should be noted that I am using Material-UI version 4.
My KeyboardDatesPicker:
<KeyboardDatePicker
format="MM/dd/yyyy"
margin="normal"
id="date-picker-inline"
defaultValue={props.value}
value={selectedDate}
required={props.required}
showTodayButton={true}
disableToolbar
inputVariant="outlined"
variant="inline"
onChange={(selectedDate) => setSelectedDate(selectedDate)}
KeyboardButtonProps={{
"aria-label": "change date",
}}
keyboardIcon={<Icon icon={ICONS.Cool_icon} />}
className={classes.componentStyle} // do not overide , but puts on top
/>