英文:
How to change the height of MUI Datepicker input box in MUI Material v6
问题
The height property passed via sx through textField and slotProps is only affecting the Paper component.这个通过sx通过textField和slotProps传递的height属性只影响了Paper组件。
英文:
<Paper elevation={0}>
<DatePicker
fullWidth
views={['year', 'month', 'day']}
openTo='month'
value={initialDate}
slotProps={{ textField: { sx: { height: '10px' } } }}
onChange={(newValue) => handleInitialDateChange(newValue)}
/>
</Paper>
I have the above code. For some reason the height property I passed via sx via textField via slotProps is only affecting the Paper component.
Any help is appreciated.
答案1
得分: 1
以下是您要翻译的内容:
我在查找文档时发现的一个丑陋的解决办法是这样的:
sx={{
'& .MuiInputBase-root': {
height: '43px',
},
}}
组件看起来像这样:
<Paper elevation={0}>
<DatePicker
fullWidth
views={['year', 'month', 'day']}
openTo='month'
value={finalDate}
sx={{
'& .MuiInputBase-root': {
height: '43px',
},
}}
onChange={(newValue) => handleFinalDateChange(newValue)}
/>
</Paper>
我真的很希望有更好的方法来解决这个问题。如果没有的话,我想现在是时候为 MUI 团队提出功能请求了。
英文:
An ugly hack that I found after a bit of documentation dumpster diving is this:
sx={{
'& .MuiInputBase-root': {
height: '43px',
},
}}
The component looks like this:
<Paper elevation={0}>
<DatePicker
fullWidth
views={['year', 'month', 'day']}
openTo='month'
value={finalDate}
sx={{
'& .MuiInputBase-root': {
height: '43px',
},
}}
onChange={(newValue) => handleFinalDateChange(newValue)}
/>
</Paper>
I would really appreciate a better way to do this, though. If there isn't, well I guess its time I put in a feature request for the MUI team.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论