【发布时间】:2021-04-15 16:28:58
【问题描述】:
我尝试了 CSS 的许多变体,但它似乎不允许我更改自动完成组件的轮廓颜色/边框颜色的“焦点”状态。提前感谢,因为我浪费了几个小时试图弄清楚如何改变颜色!我需要它是绿色而不是当前的蓝色。
const GreenAutocomplete = withStyles({
root: {
'&.MuiAutocomplete-popper': {
outlineColor: '#68d0af',
borderColor: '#68d0af',
},
'&.MuiAutocomplete-fullWidth': {
outlineColor: '#68d0af',
borderColor: '#68d0af',
},
'&.MuiAutocomplete-inputFocused': {
outlineColor: '#68d0af',
borderColor: '#68d0af',
},
'&.MuiAutocomplete-input:focus': {
outlineColor: '#68d0af',
borderColor: '#68d0af',
},
'&.Mui-focused': {
outlineColor: '#68d0af',
borderColor: '#68d0af',
}
},
})(Autocomplete);
const GreenTextField = withStyles({
root: {
'&.MuiAutocomplete-fullWidth': {
outlineColor: '#68d0af',
borderColor: '#68d0af',
},
'&.MuiAutocomplete-inputFocused': {
outlineColor: '#68d0af',
borderColor: '#68d0af',
},
'&.Mui-focused': {
outlineColor: '#68d0af',
borderColor: '#68d0af',
}
},
})(TextField);
<GreenAutocomplete
multiple
id="tags-filled"
options={suggestions.map((option) => option.name)}
onChange={(e,v) => {
console.log('authocomplete -> e', e)
console.log('authocomplete -> v', v) // This is an array
}}
// defaultValue={[top100Films[13].title]}
fullWidth
freeSolo
renderTags={(value, getTagProps) =>
value.map((option, index) => (
<Chip variant="outlined" label={option} {...getTagProps({ index })} />
))
}DateTextField
DOBTextField
renderInput={(params) => (
<GreenTextField {...params} variant="outlined" placeholder="Tags" />
)}
/>
【问题讨论】:
-
我试过了,但错误消息指出我唯一可以覆盖的类是“root”。 @b3hr4d
标签: reactjs material-ui material-design