如果您在此处查看组件:https : //material-ui.com/components/selects/,您会看到单击时,标签向上移动并最小化,但也会更改颜色(以及边框/线条在定义文本的底部)。
我想出了如何更改除单击或聚焦时最小化的文本之外的所有颜色。如果有人可以请帮助我。这让我发疯
如果你能解释你是如何得出这个结论的,那就加分,这样我也可以自己学习如何做到这一点。
const useStyles = makeStyles(theme => ({
root: {
display: 'flex',
flexWrap: 'wrap',
},
formControl: {
margin: theme.spacing(1),
minWidth: 120,
},
inputLabel: {
color: 'lightgray',
focused: {
color: 'orange' // does not work
}
},
select: {
color: 'white',
'&:before': { // changes the bottom textbox border when not focused
borderColor: 'red',
},
'&:after': { // changes the bottom textbox border when clicked/focused. thought it would be the same with input label
borderColor: 'green',
}
}
}));
<FormControl className={classes.formControl}>
<InputLabel
className={classes.inputLabel}
>Number of Lists</InputLabel>
<Select
className={classes.select}
value={values.age}
onChange={handleChange}
inputProps={{
name: 'age',
id: 'age-simple',
}}
>
<MenuItem value={1}>One</MenuItem>
<MenuItem value={2}>Two</MenuItem>
</Select>
</FormControl>