Skip to content

Commit eebfce4

Browse files
jelbournmmalerba
authored andcommitted
chore: add span around tab label content (#9765)
* chore: add span around tab label content This is needed for some customization cases. * Fix flex alignment issues
1 parent bbf62cd commit eebfce4

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

src/lib/tabs/_tabs-common.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ $mat-tab-animation-duration: 500ms !default;
2828
&.mat-tab-disabled {
2929
cursor: default;
3030
}
31+
32+
&.mat-tab-label-content {
33+
display: inline-flex;
34+
justify-content: center;
35+
align-items: center;
36+
white-space: nowrap;
37+
}
3138
}
3239

3340
// Mixin styles for the top section of the view; contains the tab labels.

src/lib/tabs/tab-group.html

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@
1414
[matRippleDisabled]="tab.disabled || disableRipple"
1515
(click)="_handleClick(tab, tabHeader, i)">
1616

17-
<!-- If there is a label template, use it. -->
18-
<ng-template [ngIf]="tab.templateLabel">
19-
<ng-template [cdkPortalOutlet]="tab.templateLabel"></ng-template>
20-
</ng-template>
2117

22-
<!-- If there is not a label template, fall back to the text label. -->
23-
<ng-template [ngIf]="!tab.templateLabel">{{tab.textLabel}}</ng-template>
18+
<div class="mat-tab-label-content">
19+
<!-- If there is a label template, use it. -->
20+
<ng-template [ngIf]="tab.templateLabel">
21+
<ng-template [cdkPortalOutlet]="tab.templateLabel"></ng-template>
22+
</ng-template>
23+
24+
<!-- If there is not a label template, fall back to the text label. -->
25+
<ng-template [ngIf]="!tab.templateLabel">{{tab.textLabel}}</ng-template>
26+
</div>
2427
</div>
2528
</mat-tab-header>
2629

0 commit comments

Comments
 (0)