|
| 1 | +The Angular Material tab group helps organize content into separate views where only one view can be |
| 2 | +visible at a time. Each tab's label is shown in the tab header and the active |
| 3 | +tab's label is designated with the animated ink bar. When the list of tab labels exceeds the width |
| 4 | +of the header, pagination controls appear to let the user scroll left and right across the labels. |
| 5 | + |
| 6 | +The active tab may be set using the `selectedIndex` input or when the user selects one of the |
| 7 | +tab labels in the header. |
| 8 | + |
| 9 | +<!-- example(tab-overview) --> |
| 10 | + |
| 11 | +### Events |
| 12 | + |
| 13 | +The `selectChange` output event is emitted when the active tab changes. |
| 14 | + |
| 15 | +The `focusChange` output event is emitted when the user puts focus on any of the tab labels in |
| 16 | +the header, usually through keyboard navigation. |
| 17 | + |
| 18 | +### Labels |
| 19 | + |
| 20 | +If a tab's label is only text then the simple tab-group API can be used. |
| 21 | + |
| 22 | +```html |
| 23 | +<md-tab-group> |
| 24 | + <md-tab label="One"> |
| 25 | + <h1>Some tab content</h1> |
| 26 | + <p>...</p> |
| 27 | + </md-tab> |
| 28 | + <md-tab label="Two"> |
| 29 | + <h1>Some more tab content</h1> |
| 30 | + <p>...</p> |
| 31 | + </md-tab> |
| 32 | +</md-tab-group> |
| 33 | +``` |
| 34 | + |
| 35 | +For more complex labels, add a template with the `md-tab-label` directive inside the `md-tab`. |
| 36 | + |
| 37 | +```html |
| 38 | +<md-tab-group> |
| 39 | + <md-tab> |
| 40 | + <template md-tab-label> |
| 41 | + The <em>best</em> pasta |
| 42 | + </template> |
| 43 | + <h1>Best pasta restaurants</h1> |
| 44 | + <p>...</p> |
| 45 | + </md-tab> |
| 46 | + <md-tab> |
| 47 | + <template md-tab-label> |
| 48 | + <md-icon>thumb_down</md-icon> The worst sushi |
| 49 | + </template> |
| 50 | + <h1>Terrible sushi restaurants</h1> |
| 51 | + <p>...</p> |
| 52 | + </md-tab> |
| 53 | +</md-tab-group> |
| 54 | +``` |
| 55 | + |
| 56 | +### Dynamic Height |
| 57 | + |
| 58 | +By default, the tab group will not change its height to the height of the currently active tab. To |
| 59 | +change this, set the `dynamicHeight` input to true. The tab body will animate its height according |
| 60 | + to the height of the active tab. |
0 commit comments