【问题标题】:createMuiTheme overrides, for a particular component stylecreateMuiTheme 覆盖,用于特定的组件样式
【发布时间】:2019-12-18 21:35:00
【问题描述】:

是否可以覆盖特定 Material UI 组件样式的默认样式?假设我想要不同类型的MuiButton...

<Button color="primary" variant="contained">Foo</Button>
<Button variant="text">Foo</Button>

在默认样式下,第一个按钮的文本颜色为白色,第二个按钮的文本颜色为黑色。如果我想全局更改文本颜色默认值(在这种情况下我不会),我应该为createMuiTheme 使用以下选项:

const options = {
  overrides: {
    MuiButton: {
      root: {
          color: 'white',
      }
    }
  }
};

但是在这种情况下,我只想更改原色和包含变体按钮的文本颜色。我该怎么做?

【问题讨论】:

    标签: material-ui


    【解决方案1】:

    来自the documentation,我不太清楚,但显然您可以像这样针对组件中的不同类:

    const options = {
      overrides: {
        MuiButton: {
          containedPrimary: {
            '& > .MuiButton-label': {
              color: 'white'
            },
          }
        }
      }
    };
    

    【讨论】:

      猜你喜欢
      • 2019-10-20
      • 2022-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-28
      • 1970-01-01
      相关资源
      最近更新 更多