首页 > 解决方案 > Material-UI TextField:控制边框颜色

问题描述

强调文本如何控制 MUI TextField 的边框颜色?

<DarkTextField
  variant="outlined"
  margin="dense"
  inputRef={input => (this.input = input)}
  onKeyPress={this.onKeyPressed}
  type="text"
  placeholder="Name"
/>

我尝试了如下几种组合:

const styles = {
  border: {
    "&::before": {
      border: "1px solid #90caf9"
    },
    "&:hover:not(.Mui-disabled):before": {
      border: "2px solid #90caf9"
    },
    "&::after": {
      border: "2px solid #90caf9"
    }
  }
};

const DarkTextField = withStyles(styles)(props => {
  const { classes, ...other } = props;

  return <TextField InputProps={{ className: classes.border }} {...other} />;
});

我不知道如何指定边界。另外,我想控制占位符文本的颜色。

标签: material-ui

解决方案


推荐阅读