I have update the solution to work on Production env. ng-reflect attribute may not be available in prod env.
OLD - works in dev env only.
I have read all above solutions. I want to share mine. You only need below two properties to understand, no need to create custom index.
[ng-reflect-selected='false'] and [ng-reflect-active='true']
There are three states of above two.
[ng-reflect-selected='true'] and [ng-reflect-active='true']
- It represent current state - it means currently this stepper header is active.
[ng-reflect-selected='false'] and [ng-reflect-active='true']
- It represent previous state - it means you have already move on from this stepper header.
[ng-reflect-selected='false'] and [ng-reflect-active='false']
- It represent next state - it means you have yet to move on from current stepper header.
Now come to the solution. To achieve this state.
you need to use this [ng-reflect-selected='false'] and [ng-reflect-active='true']
.mat-horizontal-stepper-header {
&[ng-reflect-selected='false'][ng-reflect-active='true'] + .mat-stepper-horizontal-line {
border-color: #4ca131; //green color
}
}
The above CSS structure converted in HTML looks like
<element class="mat-horizontal-stepper-header" ng-reflect-selected="false"
ng-reflect-active="true">
<element class="mat-stepper-horizontal-line">
It will change the horizontal line color before current header.
UPDATE - works in both dev and production env.
The above solution might not work in production env as ng-reflect attributes may not be available. For that you can check below solution - as aria-selected attribute is available in both dev and prod env.
.mat-horizontal-stepper-header .mat-stepper-horizontal-line {
border-top-color: green; //Green Color
border-top-width: 1px;
border-top-style: solid;
}
.mat-horizontal-stepper-header[aria-selected='true'] ~ .mat-stepper-horizontal-line{
border-top-color: hsl(0, 0%, 50%) !important;
}
What above I have done is by default I made all horizontal line color to green and then owerrite all horizontal line color to grey after the selected/current wizard step.This will makes all previous visited stepper header to green.