【问题标题】:Change the font size of a label material-ui更改标签材质-ui的字体大小
【发布时间】:2019-04-11 00:19:00
【问题描述】:

我就是想不通这个家伙。我想用我的文本字段更改标签的字体大小。到目前为止,我只能更改输入的字体大小,但不能更改标签。

文本字段:

<TextField
 className={classes.TextField}
 id="input-with-icon-textfield"
 label="Zoeken"
 InputProps={{
 startAdornment: (
                  <InputAdornment position="start">
                         <Search />
                  </InputAdornment>
                                  ),
                 }}
 onChange={(e) => {this.setTextFilter(e.target.value);}}
 />

添加了一张图片,这样您就可以通过标签了解我的意思。

【问题讨论】:

  • 在这里也发布你的渲染 html

标签: javascript reactjs material-ui


【解决方案1】:

我最终在我的主要 mui 主题中添加了一些代码。

const theme = createMuiTheme({
palette: {
  primary: {
    main: '#39870c',
    ligth: '#6cb842',
    dark: '#005900'
  },
  secondary: {
    light: '#01689b',
    main: '#0044ff',
    contrastText: '#ffcc00',
  },
},
overrides: {
  MuiInputLabel: { 
    root: { 
      color:'black',
      fontSize: 13, 
    },
  },
}


}); 

有了覆盖,我基本上可以改变任何东西。我希望这对将来的人有所帮助,因为这真的很烦人。

【讨论】:

  • 谢谢哥们。它对我很有效。快乐编码:)
【解决方案2】:

这里的另一个选项: insted 覆盖您可以用作标签道具内的 Typography 组件。看例子

<TextField 
  label={
    <Typography variant="headline" component="h3"> Zoeken </Typography>
  } ..../>

希望这会对某人有所帮助。

【讨论】:

    猜你喜欢
    • 2019-06-28
    • 1970-01-01
    • 2018-10-23
    • 2019-08-12
    • 2019-07-19
    • 1970-01-01
    • 1970-01-01
    • 2019-03-24
    相关资源
    最近更新 更多