Skip to content

Commit c98e84c

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

File tree

5 files changed

+24
-19
lines changed

5 files changed

+24
-19
lines changed
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
.mat-tab-group {
2-
margin-bottom: 48px;
1+
.example-action-button {
2+
margin-top: 8px;
3+
margin-bottom: 8px;
4+
margin-right: 8px;
35
}
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 -->

src/components-examples/material/tabs/tab-group-align/tab-group-align-example.ts

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
/**
@@ -9,6 +10,8 @@ import {MatTabsModule} from '@angular/material/tabs';
910
templateUrl: 'tab-group-align-example.html',
1011
styleUrl: 'tab-group-align-example.css',
1112
standalone: true,
12-
imports: [MatTabsModule],
13+
imports: [MatTabsModule, MatButtonModule],
1314
})
14-
export class TabGroupAlignExample {}
15+
export class TabGroupAlignExample {
16+
alignment: 'start' | 'center' | 'end' = 'start';
17+
}

src/dev-app/tabs/tabs-demo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ <h3>Inverted Tabs</h3>
2525
<h3>Ink bar fit to content</h3>
2626
<tab-group-ink-bar-example></tab-group-ink-bar-example>
2727
<h3>Tab group with the headers on the bottom</h3>
28-
<tab-group-header-below-example></tab-group-header-below-example>
28+
<tab-group-header-below-example></tab-group-header-below-example>

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)