The BottomNavigation component provides a simple way to navigate between different views while providing common UI for both iOS and Android platforms. The recommended scenario suitable for BottomNavigation is a high level navigation with 3 to 5 tabs each with separate function. For additional information and details about bottom navigation refer to the Material Design guidelines.
Note: NativeScript 6 introduced two new UI components called BottomNavigation and Tabs. The idea behind them is to provide more control when building tab based UI, while powering the CSS styling, the icon font support and other specific functionalities. Prior to NativeScript 6, we had the TabView component which had top and bottom implementations with different behavoirs for the different platofrms and some styling limitations. With BottomNavigaiton and Tabs coomponents available, the TabView can be considered obsolete.
The BottomNavigation component roundup:
Component Primary Objectives:
Used for High Level navigation.
Good for UX structure with 3 to 5 different options.
Greater control over styling (copared to TabVIew).
The BottomNavigation component contains two sub-components:
The TabStrip which defines and rendres the bottom bar and its TabStripItem components.
Multiple TabContentItem components which total number should be equal to the number of the tabs (TabStripItem components). Each TabContentItem acts as a container for your tab content.
<BottomNavigationselectedIndex="1"><!-- The bottom tab UI is created via TabStrip (the containier) and TabStripItem (for each tab)--><TabStrip><TabStripItem><Labeltext="Home"></Label><Imagesrc="font://"class="fas"></Image></TabStripItem><TabStripItemclass="special"><Labeltext="Account"></Label><Imagesrc="font://"class="fas"></Image></TabStripItem><!--
The below two conventions (shorthand vs exteded syntax) are identical in UI outcome but the second one will provide you with greater control over your TabStripItem UI.
When using the first shorthand syntax then your Icon Font CSS class should be set on the BottomNavigation element.
--><!-- <TabStripItem title="Search" iconSource="font://"></TabStripItem> --><TabStripItemclass="special"><Labeltext="Search"></Label><Imagesrc="font://"class="fas"></Image></TabStripItem></TabStrip><!-- The number of TabContentItem components should corespond to the number of TabStripItem components --><TabContentItem><GridLayout><Labeltext="Home Page"class="h2 text-center"></Label></GridLayout></TabContentItem><TabContentItem><GridLayout><Labeltext="Account Page"class="h2 text-center"></Label></GridLayout></TabContentItem><TabContentItem><GridLayout><Labeltext="Search Page"class="h2 text-center"></Label></GridLayout></TabContentItem></BottomNavigation>
Note: The number of TabStripItem components must be equal to the number of tabContentItem components.