首页 > 解决方案 > React JS - 如何在对话框的 PaperProps 中添加样式(material-ui)

问题描述

我正在使用 Material-ui ReactJs 中的对话框组件。

<Dialog fullScreen open={this.state.open}
  PaperProps={{ classes: {root: classes.dialogPaper} }}
  onClose={this.handleClose.bind(this)} transition={this.props.transition}>
  {this.props.children}
</Dialog>

在上面的代码中,我已经覆盖了 PaperProps 的根类。现在我还想覆盖 PaperProps 中的样式。在 PaperProps 中是否可以覆盖样式。

就像是PaperProps={{ classes: {root: classes.dialogPaper}, style:{} }}

如果我错了,请告诉我。我也想覆盖样式。

标签: reactjsdialogmaterial-uiinline-stylesoverriding

解决方案


我得到了答案

<Dialog
{...otherProps}
  PaperProps={{
    style: {
      backgroundColor: 'transparent',
      boxShadow: 'none',
    },
  }}
>
  {/* ... your content ... */}
</Dialog>

这就是我们如何在对话框组件的 PaperProps 中放置样式。


推荐阅读