我们想更改 Material-ui 自动完成组件上的文本颜色、轮廓和填充。
代码如下所示:
<FormControlLabel
label="Please enter desired service:"
labelPlacement="start"
control={
<Autocomplete
id="services"
options={props.serviceTypes}
getOptionLabel={option => option.name}
className={classes.inputRoot}
style={{ width: 400, paddingLeft: 20 }}
renderInput={params => (
<TextField
{...params}
label=""
className={classes.inputRoot}
variant="outlined"
fullWidth
/>
)}
onChange={setService}
/>
}
/>
Run Code Online (Sandbox Code Playgroud)
我们可以通过这样的代码更改 TextInput 颜色
InputProps={{
className: classes.inputColor
}}
Run Code Online (Sandbox Code Playgroud)
但是以这种方式应用样式会影响 AutoComplete 功能(它失去了自动完成功能并且表现得像一个普通的 TextField)。
我们尝试了许多 style 和 className 选项都无济于事。
感谢任何建议。