简体   繁体   English

使用 CSS API 在 Material UI Stepper 中覆盖 CSS 样式

[英]Overriding CSS styles in Material UI Stepper with CSS API

I would like to change text color (which is actually a SVG Icon) in Material UI StepIcon only for active and completed steps.我想更改 Material UI StepIcon 中的文本颜色(实际上是一个 SVG 图标),仅用于活动和已完成的步骤。 At the moment, I successfully changed color of an icon for those steps.目前,我成功地更改了这些步骤的图标颜色。 That's how my MuiTheme looks like now.这就是我的MuiTheme现在的样子。

export default createMuiTheme({
  overrides: {
    MuiStepIcon: {
      root: {
        '&$active': {
          color: styles.myGreen,
        },
        '&$completed': {
          color: styles.myGreen,
        },
      },
    }
  },
});

And whole stepper looks like:整个步进器看起来像:

应用颜色的步进器

Assumings, I would like to change color of tick to gray (which represents completed steps) and color of number two to gray as well (which represents currently active step), while keeping inactive step not changed (white fill).假设,我想将刻度的颜色更改为灰色(表示已完成的步骤),并将第二号的颜色也更改为灰色(表示当前活动的步骤),同时保持非活动步骤不变(白色填充)。

Changing fill property for text like in official documentation does not give any results, in developer inspector still shows fill equal white.像在官方文档中那样更改文本的填充属性不会产生任何结果,在开发人员检查器中仍然显示填充等于白色。

I want to apply that styling for whole app.我想将该样式应用于整个应用程序。

Any tips or solution for this one?对此有任何提示或解决方案吗?

you need to override the text class too你也需要覆盖文本类

export default createMuiTheme({
  overrides: {
    MuiStepIcon: {
      root: {
        '&$active': {
          color: styles.myGreen,
        },
        '&$completed': {
          color: styles.myGreen,
        },
      },
      text: {
        fill: <YOUR_DESIRED_COLOR>
      },
     },
    }
  },
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM