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] Cannot customize StepIcon via rule name for style override

See original GitHub issue
  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

The StepIcon’s completed property does not have the override style applied.

Expected Behavior 🤔

The StepIcon’s completed property should have the override style applied. For example, the icon color should be green on completed={true} if the theme override has color: "green".

Steps to Reproduce 🕹

https://codesandbox.io/s/epic-hawking-ijkyj?file=/src/App.tsx

    MuiStepIcon: {
      styleOverrides: {
        completed: {
          color: "green",
        },
      },
    },

Using the rule name of the component’s styleOverrides property in a custom theme is not applied.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

4reactions
siriwatknpcommented, Jun 28, 2021

Summary of this issue

to customize completed state for StepIcon, use pseudo class stepIconClasses.completed or 'Mui-completed'.

MuiStepIcon: {
  styleOverrides: {
    root: {
      '&.Mui-completed': {
        color: 'forestgreen',
      }
    },
  },
},
1reaction
michal-perlakowskicommented, Jun 24, 2021

@siriwatknp That fix doesn’t seem to be working. Based on the Dialog implementation, I think it should be like this:

diff --git a/packages/material-ui/src/StepIcon/StepIcon.js b/packages/material-ui/src/StepIcon/StepIcon.js
--- a/packages/material-ui/src/StepIcon/StepIcon.js	(revision 6ef3bbe657c9447d649ef044d45e9bdec2c5d86d)
+++ b/packages/material-ui/src/StepIcon/StepIcon.js	(date 1624528599570)
@@ -23,17 +23,20 @@
 const StepIconRoot = styled(SvgIcon, {
   name: 'MuiStepIcon',
   slot: 'Root',
-  overridesResolver: (props, styles) => styles.root,
-})(({ theme }) => ({
+  overridesResolver: ({ styleProps }, styles) => ([
+    styles.root,
+    (styleProps.completed && styles.completed),
+  ]),
+})(({ theme, styleProps }) => ({
   /* Styles applied to the root element. */
   display: 'block',
   transition: theme.transitions.create('color', {
     duration: theme.transitions.duration.shortest,
   }),
   color: theme.palette.text.disabled,
-  [`&.${stepIconClasses.completed}`]: {
+  ...(styleProps.completed && {
     color: theme.palette.primary.main,
-  },
+  }),
   [`&.${stepIconClasses.active}`]: {
     color: theme.palette.primary.main,
   },
Read more comments on GitHub >

github_iconTop Results From Across the Web

[Stepper] Cannot customize StepIcon via rule name for style ...
The StepIcon's completed property should have the override style applied. For example, the icon color should be green on completed={true} if the ...
Read more >
Override the default icon from mat-stepper angular material
I've created an example where the default edit icon is changed: Stackblitz. Move your definition of the changed edit icon outside of the ......
Read more >
StepIcon API - Material UI - MUI
You can override the style of the component using one of these customization options: With a global class name. With a rule name...
Read more >
React MUI StepIcon API - GeeksforGeeks
Material-UI is a UI library providing predefined robust and customizable components for React for easier web development. The MUI design is ...
Read more >
How to customize the icons of a Stepper in Material-UI React
We can customize the icon of each step in a Stepper of Material-UI. Each step icons can be customized using a simple trick....
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