|
1 | | -## TabBar |
| 1 | +## Tab Bar |
| 2 | + |
| 3 | +Tabs organize and allow navigation between groups of content that are related and at the same level of hierarchy. The Tab Bar contains the Tab Scroller and Tab components. |
2 | 4 |
|
3 | 5 | ### Markup |
4 | 6 |
|
5 | 7 | ```html |
6 | | -<m-tab-bar scrollable> |
7 | | - <m-tab href="#home"> |
| 8 | +<m-tab-bar> |
| 9 | + <m-tab-scroller> |
| 10 | + <m-tab> |
| 11 | + <m-icon slot="icon" icon="home"/> |
| 12 | + Home |
| 13 | + </m-tab> |
| 14 | + <m-tab> |
| 15 | + <m-icon slot="icon" icon="favorite"/> |
| 16 | + Like me |
| 17 | + </m-tab> |
| 18 | + <m-tab> |
| 19 | + <m-icon slot="icon" icon="person"/> |
| 20 | + About me |
| 21 | + </m-tab> |
| 22 | + </m-tab-scroller> |
| 23 | +</m-tab-bar> |
| 24 | +``` |
| 25 | + |
| 26 | +or the `0.x.y` versions compatible way (not suggested) |
| 27 | + |
| 28 | +```html |
| 29 | +<m-tab-bar> |
| 30 | + <m-tab> |
8 | 31 | <m-icon slot="icon" icon="home"/> |
9 | 32 | Home |
10 | 33 | </m-tab> |
11 | | - <m-tab active href="#social"> |
| 34 | + <m-tab> |
12 | 35 | <m-icon slot="icon" icon="favorite"/> |
13 | 36 | Like me |
14 | 37 | </m-tab> |
15 | | - <m-tab href="#about"> |
| 38 | + <m-tab> |
16 | 39 | <m-icon slot="icon" icon="person"/> |
17 | 40 | About me |
18 | 41 | </m-tab> |
|
23 | 46 |
|
24 | 47 | | Prop | Type | Default | Description | |
25 | 48 | |------|------|---------|-------------| |
26 | | -| scrollable | Boolean | false | whether the tab bar should be scrollable | |
27 | | -| iconTabBar | Boolean | false | should be set when there will be icons in the tab label | |
28 | | -| withIconAndText | Boolean | false | should be set when there will be icons and text in the tab label | |
| 49 | +| focusOnActivate | Boolean | true | Sets whether tabs focus themselves when activated. | |
| 50 | +| useAutomaticActivation | Boolean | true | Sets how tabs activate in response to keyboard interaction. Automatic (true) activates as soon as a tab is focused with arrow keys; manual (false) activates only when the user presses space/enter. The default is automatic (true). | |
| 51 | +| activateTab | Number | 0 | Activates the tab at the given index. | |
| 52 | +| scrollIntoView | Number | 0 | Scrolls the tab at the given index into view. | |
| 53 | +| align | String | '' | __Only use when `<m-tab-scroller>` is not provided in the default slot.__ Sets the elements inside the scroll content element to be aligned to the `start`, `center`, or `end` of the scroll content element. | |
| 54 | +### Slots |
| 55 | + |
| 56 | +| Slot | Description | |
| 57 | +|------|-------------| |
| 58 | +| default | tab bar content (tabs, or tabs within `<m-tab-scroller>`) | |
| 59 | + |
| 60 | +### Events |
| 61 | + |
| 62 | +| Event | Payload | Description | |
| 63 | +|-------|---------|-------------| |
| 64 | +| activated | {"index": number} | Emitted when a Tab is activated with the index of the activated Tab. Listen for this to update content when a Tab becomes active. | |
| 65 | + |
| 66 | +## Tab Scroller |
| 67 | + |
| 68 | +A Tab Scroller allows for smooth native and animated scrolling of tabs. |
| 69 | + |
| 70 | +### Props |
| 71 | + |
| 72 | +| Prop | Type | Default | Description | |
| 73 | +|------|------|---------|------------| |
| 74 | +| align | String | '' | Sets the elements inside the scroll content element to be aligned to the `start`, `center`, or `end` of the scroll content element. | |
29 | 75 |
|
30 | 76 | ### Slots |
31 | 77 |
|
32 | 78 | | Slot | Description | |
33 | 79 | |------|-------------| |
34 | | -| default | tab bar content (tabs) | |
| 80 | +| default | tabs | |
35 | 81 |
|
36 | 82 | ## Tab |
37 | 83 |
|
38 | 84 | ### Props |
39 | 85 |
|
40 | | -| Prop | Type | Default |Description | |
| 86 | +| Prop | Type | Default | Description | |
41 | 87 | |------|------|---------|------------| |
42 | 88 | | active | Boolean | false | whether the tab should be marked as active | |
43 | | -| label | Boolean | true | whether the label in the default slot should be visible | |
| 89 | +| spanningOnlyContent | Boolean | true | whether the label in the default slot should be visible | |
| 90 | +| focusOnActivate | Boolean | true | Sets whether the tab should focus itself when activated. | |
| 91 | +| stacked | Boolean | false | Indicates that the tab icon and label should flow vertically instead of horizontally. | |
| 92 | +| minWidth | Boolean | false | Indicates that the tab should shrink in size to be as narrow as possible without causing text to wrap. | |
| 93 | +| id | String | '' | Value of the root tab element's id attribute. | |
| 94 | +| fade | Boolean | false | __Only use when `<m-tab-indicator>` is not provided in the `indicator` slot.__ Sets up the tab indicator to fade in on activation and fade out on deactivation. | |
| 95 | +| indicatorIcon | '' | __Only use when `<m-tab-indicator>` is not provided in the `indicator` slot.__ The icon content of the tab indicator content. |
| 96 | +| indicatorIconClass | 'material-icons' | __Only use when `<m-tab-indicator>` is not provided in the `indicator` slot.__ The icon class of the tab indicator content. |
| 97 | +| href | '' | whether the tab should be a hyperlink and should use anchor tag instead of a button | |
| 98 | +> _NOTE_: The tab indicator is an underline indicator by default. You can change it to a icon indicator by setting `indicatorIcon` or `indicatorClass` to a different value or provide a `<m-tab-indicator>` in the `indicator` slot. |
44 | 99 |
|
45 | | -Non prop events are mapped to the inner button element. |
| 100 | +> _NOTE_: In case of using anchor tag for tab (`<m-tab href="some/url">`) it is required to switch off automatic activation in parent component (`<m-tab-bar :useAutomaticActivation="false">`). |
46 | 101 |
|
47 | 102 | ### Slots |
48 | 103 |
|
49 | 104 | | Slot | Description | |
50 | 105 | |------|-------------| |
51 | 106 | | default | tab label | |
52 | | -| icon | icon component | |
| 107 | +| icon | icon | |
| 108 | +| indicator | tab indicator | |
| 109 | + |
| 110 | +## Tab Indicator |
| 111 | + |
| 112 | +A Tab Indicator is a visual guide that shows which Tab is active. |
| 113 | + |
| 114 | +### Props |
| 115 | + |
| 116 | +| Prop | Type | Default | Description | |
| 117 | +|------|------|---------|------------| |
| 118 | +| fade | Boolean | false | Sets up the tab indicator to fade in on activation and fade out on deactivation. | |
| 119 | +| icon | String | '' | The icon to use when using as an icon indicator | |
| 120 | +| active | Boolean | false | Activates or deactivates the indicator. | |
| 121 | +| iconClass | String | 'material-icons' | The class applied to the icon when using as an icon indicator. | |
53 | 122 |
|
54 | 123 | ### Reference |
55 | 124 |
|
|
0 commit comments