Css 如何为helperText材质ui指定颜色以突出显示TextField中的错误
如何将颜色指定给Css 如何为helperText材质ui指定颜色以突出显示TextField中的错误,css,reactjs,material-ui,Css,Reactjs,Material Ui,如何将颜色指定给helperText材质UI以突出显示TextField中的错误。我无法在材质UI中将颜色设置为helperText 我尝试使用MuiFormHelperText-root-406应用CSS 但它不起作用 <Grid item xs={3}> <TextField label="EmailId" name="emailId" value={editItem.emailId} onChange={
helperText
材质UI以突出显示TextField
中的错误。我无法在材质UI中将颜色设置为helperText
我尝试使用MuiFormHelperText-root-406
应用CSS
但它不起作用
<Grid item xs={3}>
<TextField
label="EmailId"
name="emailId"
value={editItem.emailId}
onChange={this.editInputValue}
helperText={this.state.emailerror} />
</Grid>
.MuiFormHelperText-root-406{
color:rgba(255,0,0,0.5);
}
.MuiFormHelperText-root-406{
颜色:rgba(255,0,0,0.5);
}
添加此代码:在textField
中添加className={classes.textField}
textField: {
marginLeft: theme.spacing(1),
marginRight: theme.spacing(1),
width: 200,
'& p':{
color:'blue',
},
},
@arpita patel的答案是正确的,但您应该知道,您也可以将此添加到CSS中:
.MuiFormHelperText-root {
color:rgba(255,0,0,0.5);
}
或者基于父级执行此操作:
.MuiTextField-root p {
color:rgba(255,0,0,0.5);
}
以上每一项都对我有用。我正在使用材料UI4.0.2如果@ange loron的答案不起作用,请尝试添加!重要信息
:
.MuiFormHelperText-root {
color: rgba(255,0,0,0.5) !important;
}
我试过上面的方法,仍然不起作用。有什么建议吗?您使用的是哪个版本的材质UI?(您可以在节点模块文件夹@material ui\system\CHANGELOG.md中进行检查)尝试此操作@Prathamesh ShirshivkarI尝试了常量样式的css,但只支持react函数。我希望样式能够帮助react组件中的文本您可以分享您想要的屏幕截图吗@Prathameshirshivkar您使用的是哪个版本的材质UI?(您可以检查节点模块文件夹@material ui\system\CHANGELOG.md)
.MuiFormHelperText-root {
color: rgba(255,0,0,0.5) !important;
}