Reputation: 2672
I wont to create style like this:
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:
So, how can i make it?
Upvotes: 3
Views: 8232
Reputation: 1
change below line in html
<mat-horizontal-stepper linear #stepper ngClass="{{ 'last-edited-step-' + stepper.selectedIndex }}">
Here will be the steppers
and add below scss code to scss file.
@mixin styleStepLine($index) {
.mat-horizontal-stepper-header {
&+.mat-stepper-horizontal-line:nth-child(#{$index}) {
height: 2px;
background-image: linear-gradient(to right, #17459b 0%, #0c76c3 51%, #02a8ec 100%);
}
}
}
.last-edited-step-1 {
@include styleStepLine(2);
}
.last-edited-step-2 {
@include styleStepLine(2);
@include styleStepLine(4);
}
It will helps to change line of mat-stepper in angular according to the progress of stepper
Upvotes: 0
Reputation: 2672
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
Upvotes: 2
Reputation: 520
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;
}
Upvotes: 2