How to change material stepper line style with labelPosition="bottom"

Viewed 5879

I wont to create style like this:

enter image description here

I tried to set style for all lines under edited steps, but there is lines outside of mat-step-headers.

::ng-deep .mat-horizontal-stepper-header {
    &[ng-reflect-state='edit'] + .mat-stepper-horizontal-line {
               border-top-width: 4px;
               border-top-color: blue;
    }
}

this is the result:

enter image description here

So, how can i make it?

2 Answers

head and end of the line in the header. you can use this classes with reflect state.

.mat-stepper-label-position-bottom .mat-horizontal-stepper-header:not(:first-child)::before, [dir=rtl] .mat-stepper-label-position-bottom .mat-horizontal-stepper-header:not(:last-child)::before { 
  border-top-width: 4px;
  border-top-color: blue;
}

.mat-stepper-label-position-bottom .mat-horizontal-stepper-header:not(:last-child)::after, [dir=rtl] .mat-stepper-label-position-bottom .mat-horizontal-stepper-header:not(:first-child)::after {
  border-top-width: 4px;
  border-top-color: blue;
}

.mat-stepper-horizontal-line {
  border-top-width: 4px;
  border-top-color: blue;
}

This is my solution, maybe will help someone:

scss

::ng-deep .mat-horizontal-stepper-header {
    height: 72px !important;
    padding: 0 10px !important;
    .mat-stepper-horizontal-line {
        top: 10px !important;
    }
    .mat-step-label {
        position: fixed;
        margin-top: 15px;
        width: 200px !important;
        white-space: pre-wrap;
        text-align: center;
    }
    &::before {
        width: 0;
    }
}
.selectedIndex0 {
}
@for $i from 1 through 10 {
    .selectedIndex#{$i} {
        @extend .selectedIndex#{$i - 1};
        ::ng-deep .mat-stepper-horizontal-line:nth-child(#{$i * 2}) {
            border-top-width: 4px !important;
            border-top-color: #3f51b5 !important;
        }
    }
}

and adding [class]="'selectedIndex' + stepper.selectedIndex + ' mat-stepper-label-position-bottom'" to mat-horizontal-stepper tag

Related