我正在尝试使用 select 属性在 MUI TextField 中设置最大高度。我想设置菜单的最大高度:
<TextField
fullWidth
label="Select State"
name="state"
onChange={handleChange}
required
select
SelectProps={{ native: true }}
value={values.state}
>
{states.map((option) => (
<option
key={option.value}
value={option.value}
>
{option.label}
</option>
))}
</TextField>
我尝试使用 MenuProps
,它适用于 Select
组件,但不适用于 TextField
:
<TextField
...
SelectProps={{
MenuProps: {
sx: { maxHeight: 200 }
}
}}
...
</TextField>
我还尝试在 TextField
中设置 sx
和 style
属性。
我该如何设计它?
最佳答案
我这样做了,它有帮助
<TextField
select
label="label"
variant="standard"
SelectProps={{
MenuProps: {
sx: { height: "300px" },
},
}}
>
/// your code here
</TextField>
关于reactjs - MUI TextField 选择菜单的 maxHeight,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76007908/