admin管理员组文章数量:1403217
I have Chip
widget
const styles = {
root:{
},
chip:{
margin: "2px",
padding: "2px"
}
}
const SmartTagChip = (props) =>{
const classes = useStyles();
return(
<Chip style={{color:"white"}} clickable className={classes.chip}
color="default"
label={item.label} variant="outlined"/>:
)
}
I want to make font size bigger.
So I try but in vain.
<Chip style={{color:"white"}} clickable className={classes.chip}
I am reading document /
and found some information about CSS
root .MuiChip-root Styles applied to the root element.
I guess I should customize .MuiChip-root
class though,
How can I do this?
I have Chip
widget
const styles = {
root:{
},
chip:{
margin: "2px",
padding: "2px"
}
}
const SmartTagChip = (props) =>{
const classes = useStyles();
return(
<Chip style={{color:"white"}} clickable className={classes.chip}
color="default"
label={item.label} variant="outlined"/>:
)
}
I want to make font size bigger.
So I try but in vain.
<Chip style={{color:"white"}} clickable className={classes.chip}
I am reading document https://material-ui./api/chip/
and found some information about CSS
root .MuiChip-root Styles applied to the root element.
I guess I should customize .MuiChip-root
class though,
How can I do this?
Share Improve this question asked Aug 18, 2021 at 7:36 whitebearwhitebear 12.5k29 gold badges149 silver badges299 bronze badges 1- Try using custom CSS along with !important as a flag at the end of your CSS property. It has the highest CSS Specificity. – Erfan Motallebi Commented Aug 18, 2021 at 7:41
3 Answers
Reset to default 3You can create a style class for the chip and then access the label through a sub-selector.
export const useStyles = makeStyles(() => ({
myClassName: {
borderRadius: '9px', //some style
'& .MuiChip-label': { fontSize: 18 }, // sub-selector
},
}));
You can use built-in solution from Material-ui called withStyles. It allows to simply apply styles to ponents. In your case it will look like this:
const StyledChip = withStyles({
root: {
backgroundColor: 'red'// here you can do anything actually
},
label: {
textTransform: 'capitalize',
},
})(Chip);
const SmartTagChip = (props) =>{
const classes = useStyles();
return(
<StyledChip clickable
color="default"
label={item.label} variant="outlined"/>:
)
}
To plete Sabrina's answer
import {makeStyles} from "@mui/styles";
const useStyles = makeStyles(() => ({
chipCustom: {
borderRadius: '9px', //some style
'& .MuiChip-label': {fontSize: 18}, // sub-selector
},
}));
const customChipClass = useStyles();
<Chip className={customChipClass.chipCustom} label="Test"/>
本文标签: javascriptHow to change the font size of Chip of MaterialUIStack Overflow
版权声明:本文标题:javascript - How to change the font size of Chip of Material-UI - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744343686a2601630.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论