Skip to content

Commit 36d8502

Browse files
committed
fix(stepper): improved alignment for step icons
Switches to using absolute positioning to center the stepper icons. This works better with the text-based icons. Fixes #12696.
1 parent b2247f8 commit 36d8502

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/lib/stepper/step-header.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@
88
*ngSwitchCase="true"
99
[ngTemplateOutlet]="iconOverrides.number"
1010
[ngTemplateOutletContext]="_getIconContext()"></ng-container>
11-
<span *ngSwitchDefault>{{index + 1}}</span>
11+
<span class="mat-step-icon-content" *ngSwitchDefault>{{index + 1}}</span>
1212
</ng-container>
1313

1414
<ng-container *ngSwitchCase="'edit'" [ngSwitch]="!!(iconOverrides && iconOverrides.edit)">
1515
<ng-container
1616
*ngSwitchCase="true"
1717
[ngTemplateOutlet]="iconOverrides.edit"
1818
[ngTemplateOutletContext]="_getIconContext()"></ng-container>
19-
<mat-icon *ngSwitchDefault>create</mat-icon>
19+
<mat-icon class="mat-step-icon-content" *ngSwitchDefault>create</mat-icon>
2020
</ng-container>
2121

2222
<ng-container *ngSwitchCase="'done'" [ngSwitch]="!!(iconOverrides && iconOverrides.done)">
2323
<ng-container
2424
*ngSwitchCase="true"
2525
[ngTemplateOutlet]="iconOverrides.done"
2626
[ngTemplateOutletContext]="_getIconContext()"></ng-container>
27-
<mat-icon *ngSwitchDefault>done</mat-icon>
27+
<mat-icon class="mat-step-icon-content" *ngSwitchDefault>done</mat-icon>
2828
</ng-container>
2929
</div>
3030
<div class="mat-step-label"

src/lib/stepper/step-header.scss

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,16 @@ $mat-step-header-icon-size: 16px !default;
2626
border-radius: 50%;
2727
height: $mat-stepper-label-header-height;
2828
width: $mat-stepper-label-header-height;
29-
align-items: center;
30-
justify-content: center;
31-
display: flex;
3229
flex-shrink: 0;
30+
position: relative;
31+
}
32+
33+
.mat-step-icon-content {
34+
// Use absolute positioning to center the content, because it works better with text.
35+
position: absolute;
36+
top: 50%;
37+
left: 50%;
38+
transform: translate(-50%, -50%);
3339
}
3440

3541
.mat-step-icon .mat-icon {

0 commit comments

Comments
 (0)