Skip to content

feat(tabs): align with 2018 material design spec #12605

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/lib/tabs/tab-header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,12 @@

.mat-tab-labels {
display: flex;

[mat-align-tabs='center'] & {
justify-content: center;
}

[mat-align-tabs='end'] & {
justify-content: flex-end;
}
}
8 changes: 7 additions & 1 deletion src/lib/tabs/tabs.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ the `active` property to determine which tab is currently active. The correspond
### Lazy Loading
By default, the tab contents are eagerly loaded. Eagerly loaded tabs
will initalize the child components but not inject them into the DOM
until the tab is activated.
until the tab is activated.


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

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

<!-- example(tab-group-align) -->

### Accessibility
Tabs without text or labels should be given a meaningful label via `aria-label` or
`aria-labelledby`. For `MatTabNav`, the `<nav>` element should have a label as well.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.mat-tab-group {
margin-bottom: 48px;
}
17 changes: 17 additions & 0 deletions src/material-examples/tab-group-align/tab-group-align-example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<mat-tab-group mat-align-tabs="start">
<mat-tab label="First">Content 1</mat-tab>
<mat-tab label="Second">Content 2</mat-tab>
<mat-tab label="Third">Content 3</mat-tab>
</mat-tab-group>

<mat-tab-group mat-align-tabs="center">
<mat-tab label="First">Content 1</mat-tab>
<mat-tab label="Second">Content 2</mat-tab>
<mat-tab label="Third">Content 3</mat-tab>
</mat-tab-group>

<mat-tab-group mat-align-tabs="end">
<mat-tab label="First">Content 1</mat-tab>
<mat-tab label="Second">Content 2</mat-tab>
<mat-tab label="Third">Content 3</mat-tab>
</mat-tab-group>
11 changes: 11 additions & 0 deletions src/material-examples/tab-group-align/tab-group-align-example.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {Component} from '@angular/core';

/**
* @title Tab group with aligned labels
*/
@Component({
selector: 'tab-group-align-example',
templateUrl: 'tab-group-align-example.html',
styleUrls: ['tab-group-align-example.css'],
})
export class TabGroupAlignExample {}