Skip to content

Commit f2d7f7d

Browse files
committed
feat(tabs): align with 2018 material design spec
Aligns the tabs component with the latest Material design spec and adds the ability to align the tab labels in the middle or the end of the container.
1 parent ea10d94 commit f2d7f7d

File tree

5 files changed

+46
-1
lines changed

5 files changed

+46
-1
lines changed

src/lib/tabs/tab-header.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,12 @@
8282

8383
.mat-tab-labels {
8484
display: flex;
85+
86+
[mat-align-tabs='center'] & {
87+
justify-content: center;
88+
}
89+
90+
[mat-align-tabs='end'] & {
91+
justify-content: flex-end;
92+
}
8593
}

src/lib/tabs/tabs.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ the `active` property to determine which tab is currently active. The correspond
8383
### Lazy Loading
8484
By default, the tab contents are eagerly loaded. Eagerly loaded tabs
8585
will initalize the child components but not inject them into the DOM
86-
until the tab is activated.
86+
until the tab is activated.
8787

8888

8989
If the tab contains several complex child components or the tab's contents
@@ -108,6 +108,12 @@ with the `matTabContent` attribute.
108108
</mat-tab-group>
109109
```
110110

111+
### Label alignment
112+
If you want to align the tab labels in the center or towards the end of the container, you can
113+
do so using the `[mat-align-tabs]` attribute.
114+
115+
<!-- example(tab-group-align) -->
116+
111117
### Accessibility
112118
Tabs without text or labels should be given a meaningful label via `aria-label` or
113119
`aria-labelledby`. For `MatTabNav`, the `<nav>` element should have a label as well.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.mat-tab-group {
2+
margin-bottom: 48px;
3+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<mat-tab-group mat-align-tabs="start">
2+
<mat-tab label="First">Content 1</mat-tab>
3+
<mat-tab label="Second">Content 2</mat-tab>
4+
<mat-tab label="Third">Content 3</mat-tab>
5+
</mat-tab-group>
6+
7+
<mat-tab-group mat-align-tabs="center">
8+
<mat-tab label="First">Content 1</mat-tab>
9+
<mat-tab label="Second">Content 2</mat-tab>
10+
<mat-tab label="Third">Content 3</mat-tab>
11+
</mat-tab-group>
12+
13+
<mat-tab-group mat-align-tabs="end">
14+
<mat-tab label="First">Content 1</mat-tab>
15+
<mat-tab label="Second">Content 2</mat-tab>
16+
<mat-tab label="Third">Content 3</mat-tab>
17+
</mat-tab-group>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import {Component} from '@angular/core';
2+
3+
/**
4+
* @title Tab group with aligned labels
5+
*/
6+
@Component({
7+
selector: 'tab-group-align-example',
8+
templateUrl: 'tab-group-align-example.html',
9+
styleUrls: ['tab-group-align-example.css'],
10+
})
11+
export class TabGroupAlignExample {}

0 commit comments

Comments
 (0)