Skip to content
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

docs(material/tabs): add dynamically aligned tabs group example #29798

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.mat-tab-group {
margin-bottom: 48px;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this wasn't being used so I removed it.

.example-action-button {
margin-top: 8px;
margin-bottom: 8px;
margin-right: 8px;
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<!-- #docregion align-start -->
<mat-tab-group mat-stretch-tabs="false" mat-align-tabs="start">
<!-- #enddocregion align-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>
<button mat-raised-button class="example-action-button" (click)="alignment = 'start'">
Start
</button>

<mat-tab-group mat-stretch-tabs="false" 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>
<button mat-raised-button class="example-action-button" (click)="alignment = 'center'">
Center
</button>

<mat-tab-group mat-stretch-tabs="false" mat-align-tabs="end">
<button mat-raised-button class="example-action-button" (click)="alignment = 'end'">
End
</button>

<!-- #docregion align-start -->
<mat-tab-group mat-stretch-tabs="false" [mat-align-tabs]="alignment">
<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>
<!-- #docregion align-end -->
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Component} from '@angular/core';
import {MatButtonModule} from '@angular/material/button';
import {MatTabsModule} from '@angular/material/tabs';

/**
Expand All @@ -9,6 +10,8 @@ import {MatTabsModule} from '@angular/material/tabs';
templateUrl: 'tab-group-align-example.html',
styleUrl: 'tab-group-align-example.css',
standalone: true,
imports: [MatTabsModule],
imports: [MatTabsModule, MatButtonModule],
})
export class TabGroupAlignExample {}
export class TabGroupAlignExample {
alignment: 'start' | 'center' | 'end' = 'start';
}
2 changes: 1 addition & 1 deletion src/dev-app/tabs/tabs-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ <h3>Inverted Tabs</h3>
<h3>Ink bar fit to content</h3>
<tab-group-ink-bar-example></tab-group-ink-bar-example>
<h3>Tab group with the headers on the bottom</h3>
<tab-group-header-below-example></tab-group-header-below-example>
<tab-group-header-below-example></tab-group-header-below-example>
2 changes: 1 addition & 1 deletion src/material/tabs/tabs.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ with the `matTabContent` attribute.

### 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.
do so using the `mat-align-tabs` input or attribute.

<!-- example({"example": "tab-group-align",
"file": "tab-group-align-example.html",
Expand Down
Loading