|
| 1 | +[](https://www.npmjs.com/package/nativescript-material-bottom-navigation) |
| 2 | +[](https://www.npmjs.com/package/nativescript-material-bottom-navigation) |
| 3 | +[](https://github.com/Akylas/nativescript-material-components/network) |
| 4 | +[](https://github.com/Akylas/nativescript-material-components/stargazers) |
| 5 | + |
| 6 | +## Installation |
| 7 | + |
| 8 | +### Warning :warning: :warning: |
| 9 | +From 5.x using material component will break N tab component on iOS (which is bound to be removed). This is needed to allow using the latest native iOS features. If needed you can use either [bottomnavigationbar](https://www.npmjs.com/package/nativescript-material-bottomnavigationbar) (this one is the best choice, closest to material design) or [tabs](https://www.npmjs.com/package/nativescript-material-bottom-navigation) (clone of N one, but with a little less features) |
| 10 | + |
| 11 | +* `tns plugin add @nativescript-community/ui-material-bottom-navigation` |
| 12 | + |
| 13 | +Be sure to run a new build after adding plugins to avoid any issues. |
| 14 | + |
| 15 | +--- |
| 16 | + |
| 17 | +##### [Material Design Spec](https://material.io/design/components/bottom-navigation.html) |
| 18 | + |
| 19 | +### Usage |
| 20 | + |
| 21 | + |
| 22 | +## Plain NativeScript |
| 23 | + |
| 24 | +<span style="color:red">IMPORTANT: </span>_Make sure you include `xmlns:mds="@nativescript-community/ui-material-bottom-navigation"` on the Page element_ |
| 25 | + |
| 26 | +### XML |
| 27 | + |
| 28 | +```XML |
| 29 | +<Page xmlns:mdt="@nativescript-community/ui-material-bottom-navigation"> |
| 30 | + <mdt:Tabs selectedIndex="1"> |
| 31 | + <!-- The bottom tab UI is created via TabStrip (the containier) and TabStripItem (for each tab)--> |
| 32 | + <MDTabStrip> |
| 33 | + <MDTabStripItem> |
| 34 | + <Label text="Home"></Label> |
| 35 | + <Image src="font://" class="fas"></Image> |
| 36 | + </TabStripItem> |
| 37 | + <TabStripItem class="special"> |
| 38 | + <Label text="Account"></Label> |
| 39 | + <Image src="font://" class="fas"></Image> |
| 40 | + </TabStripItem> |
| 41 | + <TabStripItem class="special"> |
| 42 | + <Label text="Search"></Label> |
| 43 | + <Image src="font://" class="fas"></Image> |
| 44 | + </TabStripItem> |
| 45 | + </TabStrip> |
| 46 | + |
| 47 | + <!-- The number of TabContentItem components should corespond to the number of TabStripItem components --> |
| 48 | + <MDTabContentItem> |
| 49 | + <GridLayout> |
| 50 | + <Label text="Home Page" class="h2 text-center"></Label> |
| 51 | + </GridLayout> |
| 52 | + </TabContentItem> |
| 53 | + <MDTabContentItem> |
| 54 | + <GridLayout> |
| 55 | + <Label text="Account Page" class="h2 text-center"></Label> |
| 56 | + </GridLayout> |
| 57 | + </TabContentItem> |
| 58 | + <MDTabContentItem> |
| 59 | + <GridLayout> |
| 60 | + <Label text="Search Page" class="h2 text-center"></Label> |
| 61 | + </GridLayout> |
| 62 | + </TabContentItem> |
| 63 | + </Tabs> |
| 64 | +</Page> |
| 65 | +``` |
| 66 | + |
| 67 | +### CSS |
| 68 | + |
| 69 | +```CSS |
| 70 | +MDBottomNavigation.bottom-nav { |
| 71 | + background-color: orangered; |
| 72 | + color: gold; |
| 73 | + font-size: 18; |
| 74 | +} |
| 75 | + |
| 76 | +TabStripItem.tabstripitem-active { |
| 77 | + background-color: teal; |
| 78 | +} |
| 79 | + |
| 80 | +TabStripItem.tabstripitem-active:active { |
| 81 | + background-color: yellowgreen; |
| 82 | +} |
| 83 | + |
| 84 | +TabContentItem.first-tabcontent { |
| 85 | + background-color: seashell; |
| 86 | + color: olive; |
| 87 | +} |
| 88 | +TabContentItem.second-tabcontent { |
| 89 | + background-color: slategray; |
| 90 | + color: aquamarine; |
| 91 | +} |
| 92 | +TabContentItem.third-tabcontent { |
| 93 | + background-color: blueviolet; |
| 94 | + color: antiquewhite; |
| 95 | +} |
| 96 | +MDBottomNavigation TabStrip { |
| 97 | + highlight-color: red; |
| 98 | +} |
| 99 | +``` |
| 100 | + |
| 101 | +## NativeScript + Angular |
| 102 | + |
| 103 | +```typescript |
| 104 | +import { NativeScriptMaterialTabsModule } from "@nativescript-community/ui-material-slider/angular"; |
| 105 | + |
| 106 | +@NgModule({ |
| 107 | + imports: [ |
| 108 | + NativeScriptMaterialTabsModule, |
| 109 | + ... |
| 110 | + ], |
| 111 | + ... |
| 112 | +}) |
| 113 | +``` |
| 114 | + |
| 115 | +```html |
| 116 | + <MDBottomNavigation selectedIndex="1"> |
| 117 | + <!-- The bottom tab UI is created via TabStrip (the containier) and TabStripItem (for each tab)--> |
| 118 | + <MDTabStrip> |
| 119 | + <MDTabStripItem> |
| 120 | + <Label text="Home"></Label> |
| 121 | + <Image src="font://" class="fas"></Image> |
| 122 | + </TabStripItem> |
| 123 | + <TabStripItem class="special"> |
| 124 | + <Label text="Account"></Label> |
| 125 | + <Image src="font://" class="fas"></Image> |
| 126 | + </TabStripItem> |
| 127 | + <TabStripItem class="special"> |
| 128 | + <Label text="Search"></Label> |
| 129 | + <Image src="font://" class="fas"></Image> |
| 130 | + </TabStripItem> |
| 131 | + </TabStrip> |
| 132 | + |
| 133 | + <!-- The number of TabContentItem components should corespond to the number of TabStripItem components --> |
| 134 | + <MDTabContentItem> |
| 135 | + <GridLayout> |
| 136 | + <Label text="Home Page" class="h2 text-center"></Label> |
| 137 | + </GridLayout> |
| 138 | + </TabContentItem> |
| 139 | + <MDTabContentItem> |
| 140 | + <GridLayout> |
| 141 | + <Label text="Account Page" class="h2 text-center"></Label> |
| 142 | + </GridLayout> |
| 143 | + </TabContentItem> |
| 144 | + <MDTabContentItem> |
| 145 | + <GridLayout> |
| 146 | + <Label text="Search Page" class="h2 text-center"></Label> |
| 147 | + </GridLayout> |
| 148 | + </TabContentItem> |
| 149 | + </MDBottomNavigation> |
| 150 | +``` |
| 151 | + |
| 152 | +## NativeScript + Vue |
| 153 | + |
| 154 | +```javascript |
| 155 | +import BottomNavigation from '@nativescript-community/ui-material-bottom-navigation/vue'; |
| 156 | + |
| 157 | +Vue.use(BottomNavigation); |
| 158 | +``` |
| 159 | + |
| 160 | +```html |
| 161 | +<MDBottomNavigation selectedIndex="1"> |
| 162 | + <!-- The bottom tab UI is created via TabStrip (the containier) and TabStripItem (for each tab)--> |
| 163 | + <MDTabStrip> |
| 164 | + <MDTabStripItem> |
| 165 | + <Label text="Home"></Label> |
| 166 | + <Image src="font://" class="fas"></Image> |
| 167 | + </TabStripItem> |
| 168 | + <TabStripItem class="special"> |
| 169 | + <Label text="Account"></Label> |
| 170 | + <Image src="font://" class="fas"></Image> |
| 171 | + </TabStripItem> |
| 172 | + <TabStripItem class="special"> |
| 173 | + <Label text="Search"></Label> |
| 174 | + <Image src="font://" class="fas"></Image> |
| 175 | + </TabStripItem> |
| 176 | + </TabStrip> |
| 177 | + |
| 178 | + <!-- The number of TabContentItem components should corespond to the number of TabStripItem components --> |
| 179 | + <MDTabContentItem> |
| 180 | + <GridLayout> |
| 181 | + <Label text="Home Page" class="h2 text-center"></Label> |
| 182 | + </GridLayout> |
| 183 | + </TabContentItem> |
| 184 | + <MDTabContentItem> |
| 185 | + <GridLayout> |
| 186 | + <Label text="Account Page" class="h2 text-center"></Label> |
| 187 | + </GridLayout> |
| 188 | + </TabContentItem> |
| 189 | + <MDTabContentItem> |
| 190 | + <GridLayout> |
| 191 | + <Label text="Search Page" class="h2 text-center"></Label> |
| 192 | + </GridLayout> |
| 193 | + </TabContentItem> |
| 194 | + </MDBottomNavigation> |
| 195 | +``` |
| 196 | + |
| 197 | +## Attributes |
| 198 | + |
| 199 | +| Name |Type| Description| |
| 200 | +| ------------- |:-------------:| -----:| |
| 201 | +| items | Array<MDTabContentItem> | Gets or sets the items of the BottomNavigation.| |
| 202 | +|selectedIndex | number | Gets or sets the selectedIndex of the BottomNavigation.| |
| 203 | +|swipeEnabled | boolean | Gets or sets the swipe enabled state of the Tabs.| |
| 204 | +|offscreenTabLimit | number | Gets or sets the number of offscreen preloaded tabs of the Tabs.| |
| 205 | +|tabStrip |TabStrip | Gets or sets the tab strip of the BottomNavigation.| |
| 206 | +|tabsPosition | "top", "bottom" | Gets or sets the position state of the Tabs. Default value: top| |
| 207 | +|iOSTabBarItemsAlignment | "leading", "justified", "center", "centerSelected" |iOS Only: Gets or set the MDCTabBarAlignment of the tab bar icons in iOS. Default value: justified| |
| 208 | + |
| 209 | +## Events |
| 210 | + |
| 211 | +|Name | Description| |
| 212 | +| ------------- |:-------------:| -----:| |
| 213 | +|selectedIndexChanged | Emitted when the selectedIndex property is changed. |
| 214 | +|loaded | Emitted when the view is loaded. |
| 215 | +|unloaded | Emitted when the view is unloaded. |
| 216 | +|layoutChanged | Emitted when the layout bounds of a view changes due to layout processing. |
0 commit comments