【问题标题】:Change Font of TextField更改文本字段的字体
【发布时间】:2020-10-29 18:38:23
【问题描述】:

我需要为@material-ui 中的TextField 使用特定字体,这是TextField 代码:

<TextField
  id="outlined-basic"
  className={classes.inputField}
  hintText="Level Data"
  floatingLabelText="MultiLine and FloatingLabel"
  multiline
  style={{width:"75%"}}
  rows={20}
/><br />

我是 React 和 @material-ui 的新手,因此我们将不胜感激!

【问题讨论】:

    标签: reactjs input fonts material-ui


    【解决方案1】:

    由于您使用的是multiline,因此您可以选择定位textarea

    const useStyles = makeStyles((theme) => ({
      inputField: {
        "& textarea": {
          fontFamily: "monospace"
        }
      }
    }));
    


    但要完整回答,如果您不使用multiline,只需定位input 元素

    const useStyles = makeStyles((theme) => ({
      otherInputField: {
        "& input": {
          fontFamily: "monospace"
        }
      }
    }));
    

    【讨论】:

      猜你喜欢
      • 2019-06-27
      • 1970-01-01
      • 2013-10-20
      • 1970-01-01
      • 2011-09-02
      • 1970-01-01
      • 1970-01-01
      • 2012-12-21
      • 1970-01-01
      相关资源
      最近更新 更多