Material-ui: [Stepper] Override active step icon text

Created on 14 Jan 2019  路  4Comments  路  Source: mui-org/material-ui


While building out the vertical stepper I ran into a issue where the active step needed a different font color than the rest.

When looking into the svg I noticed in the .MuiStepIcon-active-# that there was no css className added after the standard className .MuiStepIcon-text-# (that used across all text field in all steps) to differentiate the active text field from the rest

  • [x] I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior 馃

deepinscreenshot_select-area_20190114154605

Current Behavior 馃槸

deepinscreenshot_select-area_20190114154959

Code 馃寛

deepinscreenshot_select-area_20190114154652

Its a bit hard to see but above is the text field which shows the issue .MuiStepIcon-text-# that is used across all text fields and no id or class to overwrite the generic css

here's the css snip that I have

const theme = createMuiTheme({
    typography: {
      useNextVariants: true,
    },
    overrides: {
        MuiStepIcon: {
            text: {
                fill: "#D3D3D3",
            },
            root: {
                color: 'white',
                border: "solid",
                borderColor: '#D3D3D3',
                borderRadius: 25,
                borderWidth: 1,

                '&$active': {
                    border: "solid",
                    borderColor: Colors.primaryColor,
                    borderRadius: 25,
                    fill: "white",
                    borderWidth: 1,
                },
                '&$completed': {
                  border: "none"
                }
            },
        },
    },
  });

Hard coded Fix 馃敠

to fix this issue I had to add the below snippet in my css files that pointed to the text field who's parent held the MuiStepIcon-active className

.MuiStepIcon-root-53.MuiStepIcon-active-54 .MuiStepIcon-text-54 {
  fill: #034691 !important;
}

This fix requires that anytime I add css to my project I have to modify the above snip with the updated numerical values to point to the correct path. Which doesn't make this a very optimal solution but the only one that seemed to work.

Stepper question

Most helpful comment

@jstephens9245 Did you try this strategy?

const theme = createMuiTheme({
  typography: {
    useNextVariants: true,
  },
  overrides: {
    MuiStepIcon: {
      root: {
        '&$active': {
          fill: 'white',
          '& $text': {
            fill: '#034691',
          },
        },
      },
      text: {
        fill: '#D3D3D3',
      },
    },
  },
});

alternatively, you can just use '& text': { instead of '& &text': {

All 4 comments

@jstephens9245 Did you try this strategy?

const theme = createMuiTheme({
  typography: {
    useNextVariants: true,
  },
  overrides: {
    MuiStepIcon: {
      root: {
        '&$active': {
          fill: 'white',
          '& $text': {
            fill: '#034691',
          },
        },
      },
      text: {
        fill: '#D3D3D3',
      },
    },
  },
});

alternatively, you can just use '& text': { instead of '& &text': {

I have just tried, it works. Happy to help.

Did anyone try to remove the tick from the icon when step is completed?
I managed to manipulate the text but the tick wont go away.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

FranBran picture FranBran  路  3Comments

mattmiddlesworth picture mattmiddlesworth  路  3Comments

mb-copart picture mb-copart  路  3Comments

activatedgeek picture activatedgeek  路  3Comments

sys13 picture sys13  路  3Comments