javascript - 如何更改Material-UI Chip的字体大小

标签 javascript css material-ui

我有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"/>:
  )
}

关于javascript - 如何更改Material-UI Chip的字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68828253/

相关文章:

css - SVG 过滤器使元素在 Safari 和移动版 Chrome 中不可见

html - CSS 宽度和边距与媒体查询不相加

javascript - 为什么 .simulate ("mouseover") 在 Jest/Enzyme 测试中不起作用?

javascript - 如何正确使用 Flex 并排对齐两个组件(Material UI + ReactJS)?

html - 第 n 个子选择器在 css 中不起作用(?)

reactjs - 将 Create-React-App 与 Material UI 结合使用

javascript - 如何使用 React 防止点击时在 &lt;input type=submit> 中发布表单

javascript - 如何将所有按顺序排列的元素分组为由分隔符类分隔的同一类?

javascript - 拉斐尔 : accessing the relative postion of a click on a closed path

javascript - Bootstrap Table更新结果