Material-ui: How to change the numbers in steps of material ui stepper

Created on 24 Jul 2018  路  6Comments  路  Source: mui-org/material-ui

I asked the question: https://stackoverflow.com/q/51492162/5946125

Steps takes the numbers which are length of the steps state array ex:

   state = {
       steps: [0, 1, 2, 3]
    };

Later this state may change to :

    this.setState({
      steps: [1,2,3,4]
    });

Or

  this.setState({
     steps: [2,3,4,5]
   }); 

and so on....
This is the code for stepper.

 <Stepper alternativeLabel nonLinear activeStep={activePage}>
        {steps.map((step, index) => {
          return (
            <Step key={index}>
               <StepLabel 
                  onClick={this.handleStep(step)}
                  disabled={dealsLoading}
               >
                {step}
              </StepLabel>
            </Step>
          );
        })}
      </Stepper>

But in all the cases my steps show only 1,2,3,4,. I need to change those numbers according to the steps' state array.

stepper

If I change initial state of steps to [1,2,5,6] (some random) also, step buttons are still 1,2,3,4. Why don't they change? Or how to change?

If I use StepLabel component it looks like and code for this:

steplable

 <Stepper alternativeLabel nonLinear activeStep={activePage}>
        {steps.map((step, index) => {
          return (
            <Step key={index}>
               <StepLabel 
                  onClick={this.handleStep(step)}
                  disabled={dealsLoading}
               >
                {step}
              </StepLabel>
            </Step>
          );
        })}
      </Stepper>

But I don't want label. I want those labels should be on step buttons.

Stepper support

Most helpful comment

Use the icon attribute of StepLabel.

All 6 comments

Use the icon attribute of StepLabel.

馃憢 Thanks for using Material-UI!

We use the issue tracker exclusively for bug reports and feature requests, however,
this issue appears to be a support request or question. Please ask on StackOverflow where the
community will do their best to help. There is a "material-ui" tag that you can use to tag your
question.

If you would like to link from here to your question on SO, it will help others find it.
If your issues is confirmed as a bug, you are welcome to reopen the issue using the issue template.

@mbrookes Can we get an example of how that would look?

Could I just do this in the icon attr? icon={<span>3</span>}

or does it need to be more specific?

@akhilaudable What does this look like for you?

@JustinStoddard

For example icon={3} or icon="A"

Line 63 in demo.tsx:

https://codesandbox.io/s/material-demo-6mdwm

@mbrookes Thank You! I ended up figuring it out :v:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

darkowic picture darkowic  路  62Comments

HZooly picture HZooly  路  63Comments

mnajdova picture mnajdova  路  105Comments

iceafish picture iceafish  路  62Comments

Bessonov picture Bessonov  路  93Comments