【问题标题】:How can I change the font color of a disabled TextField in mui?如何更改 mui 中禁用的 TextField 的字体颜色?
【发布时间】:2019-12-24 01:10:03
【问题描述】:

我需要更改 Material-UI 中禁用的 TextField 的字体颜色

我尝试了以下方法,但它不起作用:

const useStyles = makeStyles(theme => ({
  input: {
    color: theme.palette.text.primary,
  },
}));

function Example() {
  const classes = useStyles();
  return <TextField InputProps={{ className: classes.input }} />
}

【问题讨论】:

    标签: material-ui


    【解决方案1】:

    我能够弄清楚它是如何完成的:

    const useStyles = makeStyles(theme => ({
      disabledInput: {
        color: theme.palette.text.primary,
      },
    }));
    
    function Example() {
      const classes = useStyles();
      return <TextField 
        InputProps={{ classes: { disabled: classes.disabledInput } }}
      />
    }
    

    【讨论】:

      猜你喜欢
      • 2019-03-25
      • 2019-12-23
      • 2020-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-05
      • 1970-01-01
      相关资源
      最近更新 更多