Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular Material Stepper component showing label at the bottom

Using Angular Material Stepper component, how to make a stepper that looks like this sample. I want to make the stepper label appear at the bottom of the step number as shown in the sample.

I tried going through the documentations but there doesn't seem to be an option that does this.

like image 222
Temp O'rary Avatar asked Jun 04 '26 16:06

Temp O'rary


2 Answers

Afaik there is no native option to do this at the moment, like you said. What you could try is to use some CSS to style the elements as you wish.

I've just tried it and created this stackblitz. What I've used is only some CSS to overwrite the current styles to make the stepper look like in your example:

.mat-horizontal-stepper-header-container{
  margin-bottom: 20px; 
}

.mat-horizontal-stepper-header{ 
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  margin-bottom: -15px;
}

.mat-step-label{
  position: relative;
  top: 10px;
}

.mat-stepper-horizontal-line{
 margin: 0 -30px !important;
}

.mat-horizontal-stepper-header .mat-step-icon, .mat-horizontal-stepper-header .mat-step-icon-not-touched{
  margin-right: 0 !important;
}

It's not that elegant, but it seems to work.

If this is what you are looking for you should do some thorough testing with longer/shorter labels and different screen sizes.

like image 85
coreuter Avatar answered Jun 07 '26 11:06

coreuter


Now it's possible to define the position of the label for MatHorizontalStepper with the labelPosition property. Note that "end" is the default value, while "bottom" will place it under the step icon instead of at its side. E.g.:

<mat-horizontal-stepper labelPosition="bottom">
  <!-- content -->
<mat-horizontal-stepper>
like image 34
Ali Maleki Avatar answered Jun 07 '26 12:06

Ali Maleki



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!