reactjs - 如何在 react.js 的 Material UI 中更改 DialogTitle 和 DialogContent 中的字体颜色
问题描述
如何在react.js的 Material UI 中更改DialogTitle和DialogContent中的字体/文本颜色
更改Dialog的背景颜色有效,但尝试更改 Dialog 和 DialogContent 的字体颜色不起作用..
<Dialog
open={this.state.open}
aria-labelledby="alert-dialog-title"
aria-describedby="alert-dialog-description"
PaperProps={{
style: {
backgroundColor: "#fff",
},
}}
>
<DialogTitle id="alert-dialog-title">
"Use Google's location service?"
</DialogTitle>
<DialogContent>
<DialogContentText id="alert-dialog-description">
Hello
</DialogContentText>
</DialogContent>
<DialogActions>
<Button onClick={this.handleClose} color="primary">
OK
</Button>
</DialogActions>
</Dialog>
解决方案
覆盖 DialogTitle 'root' 类:
root: {
backgroundColor: theme.palette.primary.main,
'& h6': {
color: 'red'
}
}
如果要更改所有对话框,请通过覆盖主题全局执行此操作:
MuiDialogTitle: {
root: {
backgroundColor: theme.palette.primary.main,
'& h6': {
color: 'red'
}
}
}
推荐阅读
- google-api - Drive REST API 不再返回已删除评论的用户名?
- regex - 如何正确结合正则表达式并在 shell 脚本中查找
- reactjs - 超过最大更新深度反应
- apache-flink - 如何反序列化 Flink 中的外部检查点清单?
- python - 如何使用 Python 重新采样
- ruby-on-rails - current_user 在用户控制器的显示操作中为零
- sql - 外键作为复合主键的表的软删除实施失败
- kotlin - 使用 Kotlin 从字符串中的字符获取 unicode 值
- javascript - 当内部 div 为空时,如何隐藏 div?
- azure-devops - azure-devops-node-api:使用用户名和密码进行身份验证