我正在使用React的Material-ui。
我试图自定义当用户单击Mui
有什么想法吗?谢谢。
我试图自定义当用户单击Mui
<TextField>
组件时过渡到位的下划线颜色,这是jss注入以下CSS的结果:.MuiInput-underline:after {
border-bottom: 2px solid #303f9f;
}
我已经使用 styled-components theme provider,不想引入 MuiTheme provider 来使用 createMuiTheme
和 override
。
我已经使用 styled-components 重写了许多其他 Mui 组件的样式,但无法使用 styled-components 重写 .MuiInput-underline:after
。
现在我尝试使用 Mui 的 withStyles,但不确定确切的样式语义。我尝试过使用 InputProps 和 classes,但没有成功。
const styles = theme => ({
inputProps: {
underline: {
'&:after': {
border: '2px solid red'
}
}
}
});
const MyTextField = props => {
const { classes, ...rest } = props;
return (
<TextField InputProps={{ inputProps: classes.inputProps }} {...rest} />
);
};
export default withStyles(styles)(MyTextField);
有什么想法吗?谢谢。