我使用 Material-ui v5 进行学习。我在覆盖 mui Select 组件的默认样式时遇到困难。我想在将鼠标悬停在 Select 上并且处于聚焦状态时更改 Select 的颜色。目前对焦状态的颜色是这样的。
这是我的代码:
import { useState, useEffect } from 'react';
import { makeStyles } from '@mui/styles';
import { Select, MenuItem } from '@mui/material';
const useStyles = makeStyles({
select: {
'&.MuiOutlinedInput-root': {
width: '200px'
},
'& .MuiOutlinedInput-notchedOutline': {
borderColor: 'red',
'&:hover': {
borderColor: 'green'
}
},
}
})
function App() {
const classes = useStyles();
const [age, setAge] = useState('');
const handleChange = (event: SelectChangeEvent) => {
setAge(event.target.value);
};
return (
<Select …
Run Code Online (Sandbox Code Playgroud)