Skip to content

Commit 3a98da8

Browse files
authored
docs(material/tabs): Update public documentation with new mat-tab-nav-bar/panel guidance (#24316)
* 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
1 parent 31f8ae9 commit 3a98da8

File tree

7 files changed

+14
-53
lines changed

7 files changed

+14
-53
lines changed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import {TabGroupPreserveContentExample} from './tab-group-preserve-content/tab-g
2121
import {TabGroupStretchedExample} from './tab-group-stretched/tab-group-stretched-example';
2222
import {TabGroupThemeExample} from './tab-group-theme/tab-group-theme-example';
2323
import {TabNavBarBasicExample} from './tab-nav-bar-basic/tab-nav-bar-basic-example';
24-
import {TabNavBarWithPanelExample} from './tab-nav-bar-with-panel/tab-nav-bar-with-panel-example';
2524

2625
export {
2726
TabGroupAlignExample,
@@ -37,7 +36,6 @@ export {
3736
TabGroupStretchedExample,
3837
TabGroupThemeExample,
3938
TabNavBarBasicExample,
40-
TabNavBarWithPanelExample,
4139
TabGroupPreserveContentExample,
4240
};
4341

@@ -55,7 +53,6 @@ const EXAMPLES = [
5553
TabGroupStretchedExample,
5654
TabGroupThemeExample,
5755
TabNavBarBasicExample,
58-
TabNavBarWithPanelExample,
5956
TabGroupPreserveContentExample,
6057
];
6158

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
@@ -94,23 +95,14 @@ off-screen tabs in the DOM, you can set the `preserveContent` input to `true`.
9495
<!-- example(tab-group-preserve-content) -->
9596

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

115107
#### Labels
116108

0 commit comments

Comments
 (0)