我有Chip
小部件
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"/>:
)
}
我想让字体变大。
所以我尝试但徒劳。
<Chip style={{color:"white"}} clickable className={classes.chip}
我正在阅读文档 https://material-ui.com/api/chip/
并找到了一些关于 CSS
root .MuiChip-root Styles applied to the root element.
我想我应该自定义.MuiChip-root
类,
我怎样才能做到这一点?
您可以使用 Material-ui 中名为withStyles 的内置解决方案。它允许简单地将样式应用于组件。在您的情况下,它将如下所示:
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"/>:
)
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句