Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 如何为helperText材质ui指定颜色以突出显示TextField中的错误_Css_Reactjs_Material Ui - Fatal编程技术网

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;
}