【问题标题】:How to customise DialogTitle in material-ui如何在material-ui中自定义DialogTitle
【发布时间】:2019-10-09 17:25:08
【问题描述】:

我正在学习 react 和 material-ui 并尝试更新 DialogTitle 组件中字体的颜色。这个link 给出了一个覆盖对话框根类的解决方案(下面列出的代码)。如何覆盖 DialogTitle 的根类,以便更改标题的样式?

root: {
    backgroundColor: theme.palette.primary.main,
    '& h6': {
      color: 'red'
    }
  }

找到solution

<DialogTitle
    disableTypography
    id="alert-dialog-title"
    style={{ backgroundColor: 'navy', color: 'white' }}
>
    <Typography variant="h6">{ErrorBoundary.title}</Typography>
</DialogTitle>

【问题讨论】:

    标签: reactjs typescript material-ui


    【解决方案1】:

    如果您想覆盖 theme.js 文件中的 DialogTitle,或者您的主题所在的任何位置,您可以执行以下操作:

    MuiDialogTitle: {
      root: {
        color: 'blue'
      }
    }
    

    你必须提到组件类名。在每个材质 ui 组件的 API 部分,name is specified here:

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-06-06
    • 1970-01-01
    • 2019-08-30
    • 2021-04-12
    • 1970-01-01
    • 2019-12-27
    • 2018-11-23
    相关资源
    最近更新 更多