[英]change the font size of the checkbox and radio buttons labels
I am trying to change the font size of the checkbox and radio buttons labels. 我正在尝试更改复选框和单选按钮标签的字体大小。 I tried giving css to this component Checkbox but it's not changing the label's font size since the labels are added dynamically. 我尝试将css赋予此组件Checkbox,但由于标签是动态添加的,因此它不会更改标签的字体大小。 so I researched and found this links. 因此我研究并找到了此链接。 https://material-ui.com/api/radio/#css https://material-ui.com/customization/components/#overriding-styles-with-classes but this is not helping me. https://material-ui.com/api/radio/#css https://material-ui.com/customization/components/#overriding-styles-with-classes,但这对我没有帮助。 can you tell me how to fix it. 你能告诉我如何解决它。 providing my code snippet and sandbox below. 在下面提供我的代码段和沙箱。
https://codesandbox.io/s/material-demo-u95z5 https://codesandbox.io/s/material-demo-u95z5
const styles = theme => ({
root: {
display: "flex"
},
formControl: {
margin: theme.spacing.unit * 3
},
group: {
margin: `${theme.spacing.unit}px 0`
},
checkboxCSS: {
border: "1px solid red",
fontSize: 40
}
});
return (
<div className={classes.root}>
<FormControl component="fieldset" className={classes.formControl}>
<FormLabel component="legend">Gender</FormLabel>
<RadioGroup
aria-label="Gender"
name="gender1"
className={classes.group}
value={this.state.value}
onChange={this.handleRadioValueChange}
>
{radioValues.map(radio => {
return (
<FormControlLabel
value={radio.value}
control={<Radio />}
label={radio.label}
/>
);
})}
</RadioGroup>
{checkBoxvalues.map((check, index) => {
console.log("this.state[check.value]", this.state[check.value]);
return (
<FormControlLabel
key={check.value}
control={
<Checkbox
checked={check.checked}
onChange={this.handleCheckBoxChange(check.value, index)}
value={check.value}
className={classes.checkboxCSS}
/>
}
label={check.label}
/>
);
})}
</FormControl>
</div>
);
This link helped me: https://material-ui.com/api/form-control-label/#css 该链接对我有帮助: https : //material-ui.com/api/form-control-label/#css
The following works in your sandbox. 以下内容可在您的沙箱中使用。
In the classes object: 在类对象中:
{
...,
checkboxLabel: {
fontSize: 40
}
}
On the FormControlLabel component add: 在FormControlLabel组件上,添加:
classes={{
label:classes.checkboxLabel
}}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.