如何将Material UI Native Select样式设置为与Simple Select一致
问题:将Material UI Native Select选项样式调整为Simple Select菜单项样式
由于启用NVDA屏幕阅读器时Material UI的Simple Select存在问题,我选择使用Native Select组件。现需将Native Select的选项样式调整为与Simple Select的菜单项样式一致,相关代码如下,目标样式参考附图。恳请各位技术人士提供帮助。
import React from 'react'; import { makeStyles } from '@material-ui/core/styles'; import InputLabel from '@material-ui/core/InputLabel'; import FormControl from '@material-ui/core/FormControl'; import Select from '@material-ui/core/Select'; const useStyles = makeStyles((theme) => ({ formControl: { margin: theme.spacing(1), minWidth: 120, }, selectEmpty: { marginTop: theme.spacing(2), }, })); export default function NativeSelects() { const classes = useStyles(); const [state, setState] = React.useState({ age: '', name: 'hai', }); const handleChange = (event) => { const name = event.target.name; setState({ ...state, [name]: event.target.value, }); }; return ( <div> <FormControl className={classes.formControl}> <InputLabel htmlFor="age-native-simple">Age</InputLabel> <Select native value={state.age} onChange={handleChange} inputProps={{ name: 'age', id: 'age-native-simple', }} > <option value={10}>Ten</option> <option value={20}>Twenty</option> <option value={30}>Thirty</option> </Select> </FormControl> </div> ); }
目标样式:
内容的提问来源于stack exchange,提问作者samli prajapati
相关产品推荐
相关产品推荐

