Skip to content

Commit 76737ec

Browse files
devversionzelliott
andauthored
docs(material/tabs): Update public documentation with new mat-tab-nav-bar/panel guidance (#24316) (#24715)
* docs(material/tabs): Update public documentation with new mat-tab-nav-bar/panel guidance * docs(material/tabs): Fixed in-page link * docs(material/tabs): Fix demo bug Co-authored-by: Zack Elliott <zell@google.com>
1 parent 4501b25 commit 76737ec

File tree

7 files changed

+17
-56
lines changed

7 files changed

+17
-56
lines changed

src/components-examples/material/tabs/index.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
import {CommonModule} from '@angular/common';
2-
import {NgModule} from '@angular/core';
3-
import {ReactiveFormsModule} from '@angular/forms';
42
import {MatButtonModule} from '@angular/material/button';
53
import {MatButtonToggleModule} from '@angular/material/button-toggle';
64
import {MatCheckboxModule} from '@angular/material/checkbox';
75
import {MatIconModule} from '@angular/material/icon';
86
import {MatInputModule} from '@angular/material/input';
97
import {MatTabsModule} from '@angular/material/tabs';
8+
import {NgModule} from '@angular/core';
9+
import {ReactiveFormsModule} from '@angular/forms';
1010
import {TabGroupAlignExample} from './tab-group-align/tab-group-align-example';
1111
import {TabGroupAnimationsExample} from './tab-group-animations/tab-group-animations-example';
1212
import {TabGroupAsyncExample} from './tab-group-async/tab-group-async-example';
1313
import {TabGroupBasicExample} from './tab-group-basic/tab-group-basic-example';
1414
import {TabGroupCustomLabelExample} from './tab-group-custom-label/tab-group-custom-label-example';
15+
import {TabGroupDynamicExample} from './tab-group-dynamic/tab-group-dynamic-example';
1516
import {TabGroupDynamicHeightExample} from './tab-group-dynamic-height/tab-group-dynamic-height-example';
1617
import {TabGroupHarnessExample} from './tab-group-harness/tab-group-harness-example';
17-
import {TabGroupDynamicExample} from './tab-group-dynamic/tab-group-dynamic-example';
1818
import {TabGroupHeaderBelowExample} from './tab-group-header-below/tab-group-header-below-example';
1919
import {TabGroupLazyLoadedExample} from './tab-group-lazy-loaded/tab-group-lazy-loaded-example';
2020
import {TabGroupStretchedExample} from './tab-group-stretched/tab-group-stretched-example';
2121
import {TabGroupThemeExample} from './tab-group-theme/tab-group-theme-example';
2222
import {TabNavBarBasicExample} from './tab-nav-bar-basic/tab-nav-bar-basic-example';
23-
import {TabNavBarWithPanelExample} from './tab-nav-bar-with-panel/tab-nav-bar-with-panel-example';
2423

2524
export {
2625
TabGroupAlignExample,
@@ -36,7 +35,6 @@ export {
3635
TabGroupStretchedExample,
3736
TabGroupThemeExample,
3837
TabNavBarBasicExample,
39-
TabNavBarWithPanelExample,
4038
};
4139

4240
const EXAMPLES = [
@@ -53,7 +51,6 @@ const EXAMPLES = [
5351
TabGroupStretchedExample,
5452
TabGroupThemeExample,
5553
TabNavBarBasicExample,
56-
TabNavBarWithPanelExample,
5754
];
5855

5956
@NgModule({

src/components-examples/material/tabs/tab-nav-bar-basic/tab-nav-bar-basic-example.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<!-- #docregion mat-tab-nav -->
2-
<nav mat-tab-nav-bar [backgroundColor]="background">
2+
<nav mat-tab-nav-bar [backgroundColor]="background" [tabPanel]="tabPanel">
33
<a mat-tab-link *ngFor="let link of links"
44
(click)="activeLink = link"
55
[active]="activeLink == link"> {{link}} </a>
66
<a mat-tab-link disabled>Disabled Link</a>
77
</nav>
8+
<mat-tab-nav-panel #tabPanel></mat-tab-nav-panel>
89
<!-- #enddocregion mat-tab-nav -->
910

1011
<button mat-raised-button class="example-action-button" (click)="toggleBackground()">

src/components-examples/material/tabs/tab-nav-bar-with-panel/tab-nav-bar-with-panel-example.css

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/components-examples/material/tabs/tab-nav-bar-with-panel/tab-nav-bar-with-panel-example.html

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/components-examples/material/tabs/tab-nav-bar-with-panel/tab-nav-bar-with-panel-example.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,3 @@ <h3>Tab group theming</h3>
2020
<tab-group-theme-example></tab-group-theme-example>
2121
<h3>Tab navigation bar basic</h3>
2222
<tab-nav-bar-basic-example></tab-nav-bar-basic-example>
23-
<h3>Tab navigation bar with panel</h3>
24-
<tab-nav-bar-with-panel-example></tab-nav-bar-with-panel-example>

src/material/tabs/tabs.md

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ provides a tab-like UI for navigating between routes.
4646
"file": "tab-nav-bar-basic-example.html",
4747
"region": "mat-tab-nav"}) -->
4848

49-
The `tab-nav-bar` is not tied to any particular router; it works with normal `<a>` elements and uses
50-
the `active` property to determine which tab is currently active. The corresponding
51-
`<router-outlet>` can be placed anywhere in the view.
49+
The `mat-tab-nav-bar` is not tied to any particular router; it works with normal `<a>` elements and
50+
uses the `active` property to determine which tab is currently active. The corresponding
51+
`<router-outlet>` must be wrapped in an `<mat-tab-nav-panel>` component and should typically be
52+
placed relatively close to the `mat-tab-nav-bar` (see [Accessibility](#accessibility)).
5253

5354
### Lazy Loading
5455
By default, the tab contents are eagerly loaded. Eagerly loaded tabs
@@ -85,23 +86,14 @@ duration can be configured globally using the `MAT_TABS_CONFIG` injection token.
8586
"region": "slow-animation-duration"}) -->
8687

8788
### Accessibility
88-
`MatTabGroup` and `MatTabNavBar` implement different interaction patterns for different use-cases.
89-
You should choose the component that works best for your application.
90-
91-
`MatTabGroup` combines `tablist`, `tab`, and `tabpanel` into a single component with
92-
handling for keyboard inputs and focus management. You should use this component for switching
93-
between content within a single page.
94-
95-
`MatTabNavBar`, implements a navigation interaction pattern by using a `<nav>` element with anchor
96-
elements as the "tabs". You should use this component when you want your cross-page navigation to
97-
look like a tabbed interface. As a rule of thumb, you should consider `MatTabNavBar` if changing
98-
tabs would change the browser URL. For all navigation, including with `MatTabNavBar`, always move
99-
browser focus to an element at the beginning of the content to which the user is navigating.
100-
Furthermore, consider placing your `<router-outlet>` inside of a
101-
[landmark region](https://www.w3.org/TR/wai-aria-1.1/#dfn-landmark) appropriate to the page.
102-
103-
Avoid mixing both `MatTabGroup` and `MatTabNavBar` in your application. The inconsistent interaction
104-
patterns applied between the components may confuse users.
89+
`MatTabGroup` and `MatTabNavBar` both implement the
90+
[ARIA Tabs design pattern](https://www.w3.org/TR/wai-aria-practices-1.1/#tabpanel). Both components
91+
compose `tablist`, `tab`, and `tabpanel` elements with handling for keyboard inputs and focus
92+
management.
93+
94+
When using `MatTabNavBar`, you should place the `<mat-tab-nav-panel>` component relatively close to
95+
if not immediately adjacent to the `<nav mat-tab-nav-bar>` component so that it's easy for screen
96+
reader users to identify the association.
10597

10698
#### Labels
10799

0 commit comments

Comments
 (0)