选择时单选图标消失 - 使用 Material UI
Radio icon disappears on selection - using Material UI
我用过materialUI的RadioGroup组件。选择单选按钮后,单选图标(圆形)消失,只剩下标签。
const [env,setEnv]=React.useState('Development')
<Grid container spacing={3}>
<Grid item xs={3}>
<Card className={classes.card} elevation={1}>
<CardContent>
<form noValidate onSubmit={handleSubmit}>
<FormControl >
<FormLabel >Select Environment</FormLabel>
<RadioGroup value={env} onChange={(e) => setEnv(e.target.value)}>
<FormControlLabel value='Development' control={<Radio />} label="Development" />
<FormControlLabel value='Stage' control={<Radio />} label="Stage" />
<FormControlLabel value='Production' control={<Radio />} label="Production" />
</RadioGroup>
</FormControl>
</form>
</CardContent>
</Card>
</Grid>
</Grid>
我这样试过:
我是这样做的:
const theme = {
overrides: {
MuiRadio: {
root: {
color: 'green',
},
colorSecondary: {
'&$checked': {
color: 'green',
},
},
},
},
}
const muiTheme = createMuiTheme(theme)
我现在可以根据需要更改单选图标的颜色:)
我用过materialUI的RadioGroup组件。选择单选按钮后,单选图标(圆形)消失,只剩下标签。
const [env,setEnv]=React.useState('Development')
<Grid container spacing={3}>
<Grid item xs={3}>
<Card className={classes.card} elevation={1}>
<CardContent>
<form noValidate onSubmit={handleSubmit}>
<FormControl >
<FormLabel >Select Environment</FormLabel>
<RadioGroup value={env} onChange={(e) => setEnv(e.target.value)}>
<FormControlLabel value='Development' control={<Radio />} label="Development" />
<FormControlLabel value='Stage' control={<Radio />} label="Stage" />
<FormControlLabel value='Production' control={<Radio />} label="Production" />
</RadioGroup>
</FormControl>
</form>
</CardContent>
</Card>
</Grid>
</Grid>
我这样试过: 我是这样做的:
const theme = {
overrides: {
MuiRadio: {
root: {
color: 'green',
},
colorSecondary: {
'&$checked': {
color: 'green',
},
},
},
},
}
const muiTheme = createMuiTheme(theme)
我现在可以根据需要更改单选图标的颜色:)