reactjs - 如何在所有 Material UI Dialogs 上通用地设置类?
问题描述
我有很多Material UI 对话框,我想为rg-dialog
它们设置类。我该怎么办?
<Dialog
classes={{ root: 'rg-dialog' }}
open={workflowHistoryDialogVisible}
>
<DialogTitle>History</DialogTitle>
<DialogContent>
[WorkflowHistory]
</DialogContent>
<DialogActions>
<MatButton className="btn-warning text-white"
onClick={() => setWorkflowHistoryDialogVisibleAction(false)}>Close</MatButton>
</DialogActions>
</Dialog>
解决方案
如果要为材质组件全局设置样式,请尝试覆盖默认材质主题。我可能看起来像:
const themeOptions = {
overrides: {
MuiDialog: {
// your override styles here. for example, the following overrides dialog's "root" class
root: {
padding: 5
}
}
}
};
const theme = createMuiTheme(themeOptions);
然后在您的ThemeProvider
<ThemeProvider theme={theme}>
如果您不熟悉 material-ui 中的主题,请查看文档
推荐阅读
- javascript - 如何在 JSON 脚本中添加 href
- c - 一个简单的 gettext 示例在 linux 上不起作用
- c# - 为应用程序中的所有 WPF 窗口设置 FlowDirection
- axios - 将 Stripe 支付方式升级到 V3 版本
- sql-server - SQL Server 触发器:如果 A 列为空白或为空,则插入新行时将值设置为 X
- javascript - Discord.js v12 消息反应添加
- java - 从我的远程存储库中读取 JAR 时出错 [Dropbox 作为 Maven 存储库]
- mysql - mysql查询命令
- python - 如何训练具有不同长度的多变量输入的 LSTM?
- android - 如何找到你的安卓设备的公共 IP