reactjs - 如何更改 React Material UI 上的 Stepper 颜色?

标签 reactjs material-ui

enter image description here

在上面的屏幕截图中,我尝试将步骤颜色更改为:绿色表示正确,黄色表示正在进行,红色表示不正确。

我怎样才能做到这一点?

最佳答案

如果有人仍在寻找这个问题,对于 MUI 5,可以通过 sx propertystyled .

查看step有哪些类, stepIcon这样您就可以自定义样式。

<Box sx={{ width: '100%' }}>
  <Stepper activeStep={currentStep} alternativeLabel>
    {Object.keys(steps).map((stepNumber) => (
      <Step
        key={stepNumber}
        sx={{
          '& .MuiStepLabel-root .Mui-completed': {
            color: 'secondary.dark', // circle color (COMPLETED)
          },
          '& .MuiStepLabel-label.Mui-completed.MuiStepLabel-alternativeLabel':
            {
              color: 'grey.500', // Just text label (COMPLETED)
            },
          '& .MuiStepLabel-root .Mui-active': {
            color: 'secondary.main', // circle color (ACTIVE)
          },
          '& .MuiStepLabel-label.Mui-active.MuiStepLabel-alternativeLabel':
            {
              color: 'common.white', // Just text label (ACTIVE)
            },
          '& .MuiStepLabel-root .Mui-active .MuiStepIcon-text': {
            fill: 'black', // circle's number (ACTIVE)
          },
        }}>
        <StepLabel>{steps[stepNumber].label}</StepLabel>
      </Step>
    ))}
  </Stepper>
</Box>

关于reactjs - 如何更改 React Material UI 上的 Stepper 颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40326565/

相关文章:

css - 覆盖一些material-ui类样式但保留默认样式

reactjs - Material-ui - 包裹在组件中的 TableRow 不会显示复选框

material-ui - Material UI 在单元格中创建链接

reactjs - @mui/material/styles 和@mui/styles 的区别?

javascript - 无法执行if语句

reactjs - 如何在 React.js 中重定向

javascript - 调度 Action 触发,但 redux 存储不更新

javascript - redux-form: <FieldArray> + <FormSection> 用于复杂的对象数组

javascript - 使用导航后 react 空白页

meteor - Meteor React.js 教程第 2 部分中的应用程序崩溃