Skip to content

Commit cf1e2ed

Browse files
committed
docs(material/tabs): add dynamically aligned tabs group example
adds an example for dynamically aligned tabs group closes #29029
1 parent 1b3c42e commit cf1e2ed

File tree

4 files changed

+25
-16
lines changed

4 files changed

+25
-16
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
.mat-tab-group {
22
margin-bottom: 48px;
33
}
4+
5+
.example-action-button {
6+
margin-top: 8px;
7+
margin-bottom: 8px;
8+
margin-right: 8px;
9+
}
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
<!-- #docregion align-start -->
2-
<mat-tab-group mat-stretch-tabs="false" mat-align-tabs="start">
3-
<!-- #enddocregion align-start -->
4-
<mat-tab label="First">Content 1</mat-tab>
5-
<mat-tab label="Second">Content 2</mat-tab>
6-
<mat-tab label="Third">Content 3</mat-tab>
7-
</mat-tab-group>
1+
<button mat-raised-button class="example-action-button" (click)="alignment = 'start'">
2+
Start
3+
</button>
84

9-
<mat-tab-group mat-stretch-tabs="false" mat-align-tabs="center">
10-
<mat-tab label="First">Content 1</mat-tab>
11-
<mat-tab label="Second">Content 2</mat-tab>
12-
<mat-tab label="Third">Content 3</mat-tab>
13-
</mat-tab-group>
5+
<button mat-raised-button class="example-action-button" (click)="alignment = 'center'">
6+
Center
7+
</button>
148

15-
<mat-tab-group mat-stretch-tabs="false" mat-align-tabs="end">
9+
<button mat-raised-button class="example-action-button" (click)="alignment = 'end'">
10+
End
11+
</button>
12+
13+
<!-- #docregion align-start -->
14+
<mat-tab-group mat-stretch-tabs="false" [mat-align-tabs]="alignment">
1615
<mat-tab label="First">Content 1</mat-tab>
1716
<mat-tab label="Second">Content 2</mat-tab>
1817
<mat-tab label="Third">Content 3</mat-tab>
1918
</mat-tab-group>
19+
<!-- #docregion align-end -->
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {Component} from '@angular/core';
2+
import {MatButtonModule} from '@angular/material/button';
23
import {MatTabsModule} from '@angular/material/tabs';
34

45
/**
@@ -8,6 +9,8 @@ import {MatTabsModule} from '@angular/material/tabs';
89
selector: 'tab-group-align-example',
910
templateUrl: 'tab-group-align-example.html',
1011
styleUrl: 'tab-group-align-example.css',
11-
imports: [MatTabsModule],
12+
imports: [MatTabsModule, MatButtonModule],
1213
})
13-
export class TabGroupAlignExample {}
14+
export class TabGroupAlignExample {
15+
alignment: 'start' | 'center' | 'end' = 'start';
16+
}

src/material/tabs/tabs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ with the `matTabContent` attribute.
7070

7171
### Label alignment
7272
If you want to align the tab labels in the center or towards the end of the container, you can
73-
do so using the `[mat-align-tabs]` attribute.
73+
do so using the `mat-align-tabs` input or attribute.
7474

7575
<!-- example({"example": "tab-group-align",
7676
"file": "tab-group-align-example.html",

0 commit comments

Comments
 (0)