question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Stepper] Override active step icon text

See original GitHub issue

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

  • 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.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
oliviertassinaricommented, Jan 15, 2019

@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': {

1reaction
inarsincommented, Oct 28, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Stepper] Override active step icon text · Issue #14183 - GitHub
While building out the vertical stepper I ran into a issue where the active step needed a different font color than the rest....
Read more >
Material UI Override Step Icon Style - Stack Overflow
StepLabel provides a StepIconProps property that allows you pass custom props to the StepIcon component. (docs).
Read more >
StepIcon API - Material UI - MUI
Override or extend the styles applied to the component. See CSS API below for more details. completed, bool, false. Mark the step as...
Read more >
How to customize the icons of a Stepper in Material-UI React
Each step icons can be customized using a simple trick. In this post, I will show to how to customize the Stepper icons...
Read more >
Material UI - override step icon color - CodeSandbox
Material UI - override step icon color. https://github.com/mui-org/material-ui/tree/master/docs/src/pages/demos/steppers/HorizontalLinearStepper.js.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found