Repository navigation
[Tracking] Bottom navigation & tabs components #6967
Description
Overview
The TabView component is a navigation component that is usually at the base of a mobile app. As such it's very important to get it right. Following lots of reported issues and discussions, we decided to do a re-design of how the developer uses and customizes the component. This should be done by introducing several new components including BottomNavigation and Tabs and there should be no breaking changes for existing apps. See the design doc below for the detailed information.
Design
Implementation details and motivation of the feature can be found in its design document.
Tasks
NativeScript 6.0 (components released as BETA / EXPERIMENTAL)
BottomNavigation
- native implementation [Android]
- nesting navigations
- load one view at a time
- TabStrip declaration
- Angular support
Tabs
- native implementation [iOS]
- nesting navigations
- pre-load one view to the sides by default
- TabStrip declaration
- offscreenTabLimit
- tabsPosition
- swipeEnabled
- Angular support
TabStrip
- CSS background-color
TabStripItem
- CSS pseudo class :active
- CSS background-color
- CSS color
- CSS font
- CSS font-size
- CSS highlight-color
- CSS text-transform
- iconSource font-icon support
- Image instead of iconSource declaration
- Label instead of title declaration
Issues:
- [iOS Tabs] Tap on tabs does not change item - [Tabs] tabstripitem tap does not change tabs #7435
- [iOS Tabs] Tabs icons does not work - [Tabs] tabstripitem icons do not work #7436
- [iOS Tabs] A crash on swiping a content item - [Tabs] A crash on swiping a content item #7459
- [BottomNavigation]: crash when navigating without transition animation - [BottomNavigation]: crash when navigating without transition animation #7481
- [BottomNavigation] - crash when used with nativescript-advanced-webview tns-core-modules + nativescript-advanced-webview + navigation is crashing the app #7901
- [iOS][BottomNavigation] Images are not vertically centered - [iOS][BottomNavigation] Images are not vertically centered #7991
- [BottomNavigation] Calling js method onSelectedPositionChange failed - [BottomNavigation] Calling js method onSelectedPositionChange failed #8057
NativeScript 6.1 (components released as OFFICIAL)
BottomNavigation
- Vue.js support
- No TabStrip support (tabBarVisibility/no declaration)
- limit bar to 5 tabs
Tabs
- Vue.js support
- safe area improvements
- No TabStrip support (tabBarVisibility/no declaration)
TabStrip
- itemTap event: feat(TabStrip): add itemTap event #7711
TabStripItem
- tap event: feat(ios-tabs): emit tabStripItem tap event #7693
- Label title CSS support
- Image icon CSS support
Issues:
- [Tabs][Android] unable to select over one or more TabStripItem [Tabs][Android]: unable to select over one or more TabStripItem #7519
- [BottomNavigation][Android]: crash when selecting tab with no correspondent item [BottomNavigation][Android]: crash when selecting tab with no correspondent item #7526
- [Tabs][iOS] Incorrect tab bar when Tabs are wrapped in any layout - [Tabs][iOS] Incorrect tab bar when Tabs are wrapped in any layout #7531
- [iOS][Tabs] Unable to return to tab after tab with nested frame visited [Tabs][iOS]: unable to return to tab after tab with nested frame visited #7564
- [BottomNavigation][iOS] created dynamically does not shows the TabStrip - [BottomNavigation][iOS] created dynamically does not show tabstrip #7433
- [Tabs][Android] TabStripItem selection highlight not visible with TabStripItem background color set - [Tabs] TabStripItem selection highlight not visible with TabStripItem background color set #7494
- [Tabs] TabStripItem color not applied - [Tabs] TabStripItem color not applied #7495
- [Tabs] Cannot change active text color for selected tabstripitem - [Tabs] Cannot change active text color for selected tabstripitem #7507
- [BottomNav][Android] Changing tabs messes up text color of tabs - [BottomNav][Android] Changing tabs messes up text color of tabs #7623
- [Tabs][BottomNavigation] TabContentItem background color not applied - [Tabs][BottomNavigation] TabContentItem background color not applied #7496
- [Tabs][BottomNavigation] Font icon does not update to active state for selected tabstripitem - [Tabs][BottomNavigation] Font icon does not update to active state for selected tabstripitem #7506
- [BottomNavigation] Renders bottom empty space if tabstrip is not defined - [BottomNavigation] Renders bottom empty space if tabstrip is not defined #7471
- [BottomNavigation][Tabs][iOS] TabStripItem font icon doesn't apply own classes - [BottomNavigation][Tabs][iOS] TabStripItem font icon doesn't apply own classes #7547
- [iOS][Tabs][BottomNavigation] TabStrip.iosIconRenderingMode property value not respected [Tabs][BottomNavigation] TabStrip.iosIconRenderingMode property value not respected #7733
- [iOS][Tabs][BottomNavigation] Crash with TabStrip configured in code-behind [Tabs][BottomNavigation] Crash with TabStrip configured in code-behind #7692
- [BottomNav] Clipped tabstripitem title content when iconSource specified [BottomNav] Clipped tabstripitem title content when iconSource specified #7713
Angular
- [Tabs] TabStripItem does not render - [Tabs] TabStripItem does not render nativescript-angular#1884
- [BottomNavigation] TabStripItem does not render - [BottomNavigation] TabStripItem does not render nativescript-angular#1893
- Angular binding inside selectedIndexChanged event would work only if wrapped in NgZone - [BottomNavigation] Binding inside BottomNavigation/Tabs will work only if wrapped in NgZone nativescript-angular#1896
NativeScript 6.2
Issues:
- [BottomNav][iOS] Styling is completely messed up on device rotation - [BottomNav][iOS] Styling is completely messed up on device rotation #7864
- [BottomNavigation] icons in tab-strips items cannot be changed dynamically - [BottomNavigation] Icons in tab-strips items cannot be changed dynamically #7470
NativeScript vNext
BottomNavigation
- Profiling
- Tracing
- [Android] Setting the selectedIndex on BottomNavigation property makes the app crash Setting the selectedIndex on BottomNavigation property makes the app crash #7884
Tabs
- Profiling
- Tracing
- Replace MDCTabBar implementation with home-grown solution and drop material dependencies - [Request] Please separate material bottom bar into plugin #8079
- Pre-load UI offscreen [iOS] /unify lifecycle
TabBars
- BottomNavigationBar
- TabsBar
Issues:
- [BottomNav][iOS] Incorrect color applied to text in iOS 13 - [BottomNav][iOS]Incorrect color applied to icon/text #7862
- [iOS][BottomNavigation][Tabs] Nested Tabs in BottomNavigation wrong layout - [iOS][BottomNavigation][Tabs] Nested Tabs in BottomNavigation wrong layout #7562
- [iOS][Tabs][BottomNav] Crash when ProxyViewContainer first child of TabContentItem - [Tabs][BottomNav][iOS] Crash when ProxyViewContainer first child of TabContentItem #7834
- [iOS][Tabs] Quickly changing selectedIndex property causes glitches - [Tabs] Quickly changing selectedIndex property causes glitches #7694
- [iOS][Tabs] Tabs get stuck when selecting one by one from tabstrip - [Tabs][iOS] Tabs get stuck when selecting one by one from tabstrip #7827
- [iOS][Tabs] safe area issue when action bar is below tab bar on iPhone 6 - [Tabs][iOS] safe area issue when action bar is below tab bar on iPhone 6 #7828
- [iOS][Tabs] selected index does not apply - [iOS][Tabs] selected index does not apply #7831
- [iOS Tabs/BottomNavigation] Binding issues - BottomNavigation and Tabs binding issues #7455
- [Android Tabs/BottomNavigation] Binding issues - BottomNavigation and Tabs binding issues #7456
- [BottomNav] Changing tabs crashes app - [BottomNav] Changing tabs crashes app #7608
- [BottomNav] Changing tabs does not render the new tab items - [BottomNav] Changing tabs does not render the new tab items #7609
- [BottomNav] Dynamically generating tabs with font icons crashes app - [BottomNav] Dynamically generating tabs with font icons crashes app #7610
- [BottomNav] Dynamically generating tabs when the BottomNav has a class applied crashes - [BottomNav] Dynamically generating tabs when the BottomNav has a class applied crashes #7611
- [BottomNav][Android] Text field on second tab doesn't get enabled when autocapitalization is sentences - [BottomNav][Android] Text field on second tab doesn't get enabled when autocapitalization is sentences #7620
- [BottomNav][iOS] Changing tabs programatically messes up styles - [BottomNav][iOS] Changing tabs programatically messes up styles #7667
- [Tabs][iOS]: Highlighter change its position when app is minimised (in background) [Tabs][iOS]: Highlighter change its position when app is minimised (in background) #8027
Contributing
If you want to work on a task from the list, tell us and we will do our best to help you!
If you have another great idea on how to make the tab view even cooler, share it in the comments!
Discussion
Please, don't report problems here. Instead, open a new issue and link it to this one.
Let's use this discussion for suggestions and improvement ideas. We would love to hear from you!
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Activity
[-][Tracking] TabView re-design[/-][+][Tracking] Bottom navigation & tabs components[/+]webleaf commentedon Jul 26, 2019
I expect ability to use
FormattedStringforTabStripItem. I thinkTabStripItemshould extendTextBase. This would give full control over how it should look (because it behaves essentially like aButton).I do not feel any special advantages over what was before.
For example, I need combine icon font, with formatted text in tab title.
MartoYankov commentedon Jul 26, 2019
@webleaf Unfortunately, customization options are greatly limited by the underlying native implementations. For example, on iOS the
BottomNavigationTabStripItemis not even aUIView, so we can't really make it aTextBase. What we can do though, is provide the option to remove the bar and let you create your own bar with layouts and text views and animations and everything. Check out the PR - #7580. There is an example there. Will this work for you?henrychavez commentedon Jul 31, 2019
Hi guys,
I have a plugin nativescript-bottom-navigation based on
material componentsthat would be part ofnativescript-material-componentsand I'm wondering if my plugin will give you issues because I'm registering the component asBottomNavigationfor angular and in some projects the error below is appearing and another issue that already was addressed hereMartoYankov commentedon Jul 31, 2019
Hi @henrychavez
This is a known error that occurs when you use a certain newer version of
nativescript-angularand version pre 6.0 of thetns-core-modules. Either updatenativescript-angularto the latest patch or updatetns-core-modulesto 6.0. The problem should go away.There shouldn't be a problem with clashing names. You should be able to override the core modules elements. Both
nativescript-angularandnativescript-vueshould support overriding of registered elements, so the last one wins.That being said, I think there actually might be a problem with your plugin's name and its functionality. From your code I see that you are exposing
BottomNavigationBarcomponents as in, only the bar, not the whole navigation component. It's a bit confusing, but the material guidelines declareBottomNavigationandTabsmore as patterns whereas the components are theMDCBottomNavigationBarandMDCTabBar. I'm saying this because for 6.1 we will expose the ability to useBottomNavigation, but remove the default bar and use your own - see #7580. If you keep the element nameBottomNavigationfor your plugin, it will override the core modules one and this won't be possible. If you rename it toBottomNavigationBaryou will be able to combine the two and achieve more :) Let me know your thoughts.henrychavez commentedon Jul 31, 2019
Hi @MartoYankov,
I agree with you the docs are a little confusing related to
BottomNavigationandTabsthat the material design team describe in their documentation.I just review the code for
bottom-navigationthat you guys are doing and you are right, is better if I rename the plugin toBottomNavigationBarbecause I'm just exposing the component and leaving the implementation of navigation to the developer and you guys are preparing a more complete solution.I like the possibility to combine both, so in that way, the developer can use the
bottom-navigation-barthat fits their needs (you have a custom bar to support fonts and custom items, something that can't be done using theBottomNavigationVieworMDCBottomNavigationBarprovided by material components) that being said, the developer can use my plugin if they want to use what the material components provide us or your implementation of thebottom-navigation-barif they want something more custom, am I right? :Dvahidvdn commentedon Aug 8, 2019
Hey @MartoYankov
When will this be a part of the tab template when we are creating a new app with
tns createcommand? (It generates the template with the old TabView atm)manoldonev commentedon Aug 26, 2019
@vahidvdn Tab template should start generating app with BottomNavigation component for NativeScript 6.1 in September -- the changes are currently on PR NativeScript/nativescript-app-templates#79
michalMajkel commentedon Aug 29, 2019
Is it expected that on iOS placing tabs inside some other element breaks the view ?

I am using old TabView for general navigation, and now in one of my pages i want to have another tabview ( inside a CardView ), I have used new Tabs item. It looks good(ish) on android but totally doesn't work on iOS - is the scenario i'm trying to achieve possible or it is expected to be impossible ? Same code produces following results on both platforms ( left iOS, right Android )
MartoYankov commentedon Aug 29, 2019
@michalMajkel This is an interesting scenario. Can you try nesting the
Tabscomponent in a layout. See this article about nesting - https://docs.nativescript.org/core-concepts/nested-navigation#simple-rulejawa-the-hutt commentedon Sep 2, 2019
Question: Is there a way to not preload tabs at all? Essentially setting the
offscreenTabLimitto zero?. This would cause issues with swipe, but that could be disabled as well.Possible use case would be providing three different views and subsequent actions based off the same data where by the data might be a different state that would cause it to show up in only one tab at a time.
For example. I have a list of Appointments and I'd like to have them show up in 3 tabs: Requested, Responded and Scheduled.
As it stands right now with a custom Tab UI implementation, when I load a tab, I go to the database and load the data. The query to the database prefiltrs the data so that it only brings the data it needs into the specific tab. I realize there are a lot of different ways I can do this, but this is the pattern being used and I wondered if it was possible to continue with the pattern.
The alternative is to load all the data in the parent tabs view, hold it somewhere and then have the specific tabs filter the data as we transition between them. This will work fine for us in our situation, but there might be a use case for someone else where this pattern doesn't work and they'd like to keep the database queries on a per tab basis.
MartoYankov commentedon Sep 3, 2019
@jawa-the-hutt In short, you should use the
BottomNavigationcomponent. It doesn't pre-load tabs. Do you have an issue with it?Otherwise, we tried disabling pre-load with the old
TabViewcomponent. On Android it's not possible to tell the ViewPager to not pre-load tabs. We did a hacky workaround that proved to bring lots of bugs and problems.This is part of the reason why we decided to split the tab navigation. The
BottomNavigationcomponent doesn't pre-load and doesn't have a swipe gesture. TheTabspre-loads at least one tab to the sides and has the swipe gesture. Both have their use cases. We ultimately decided they can't be combined in one component safely.jawa-the-hutt commentedon Sep 5, 2019
@MartoYankov. Thanks for the info. My use case calls for the Tabs to be just below the header in the app and not at the bottom. So...in a perfect world, I'd have the functionality of the bottom navigation, but be able to position it vertically wherever I wanted in the UI.
However, I do understand having to deal with the limitations of what the native platforms give us.
MartoYankov commentedon Sep 5, 2019
@jawa-the-hutt The way I understand it the reason why the
BottomNavigationbar is on the bottom is that when you don't have the swipe gesture it's hard to reach to the top with your thumb to navigate.That being said, the scenario you want should be possible with the
BottomNavigationwithout (with a hidden) aTabStripand use a custom tab bar on top. There are also a couple of plugins that provide tab bars that you can position anywhere.6 remaining items
MartoYankov commentedon Sep 25, 2019
@PeterStaev It seems iOS 13 brought lots of breaking/behavior changes to lots of UIKit components. There are also problems with XCode11/iOS13 with our testing infrastructure too, which is the reason we couldn't extensively test everything. We are receiving increasing issue reports about this and we're aware of it. It's not connected to the BottomNav/Tabs components only.
PeterStaev commentedon Sep 25, 2019
Thanks @MartoYankov. Leave it to Apple/Google to mess up the things... 😄 I guess I will see to downgrade to XCode 10.3 and hope that Apple review wont deny the app release for not targeting iOS13 😜
AtoianAvetik commentedon Oct 4, 2019
I want to change tab indicator (bottom line) height (for android), how I can do that? Can someone please help me.
felixkrautschuk commentedon Oct 7, 2019
@AtoianAvetik
They have updated the docs here
AtoianAvetik commentedon Oct 7, 2019
Thanks @felix-idf! But I mean the height(weight) of line, not a color :)
MartoYankov commentedon Oct 8, 2019
@AtoianAvetik This isn't supported at the moment. You can open a feature request for it.
mkrierQape commentedon Oct 17, 2019
it dont work
MartoYankov commentedon Oct 21, 2019
@mkrierQape Here is a playground link from the blog post - https://play.nativescript.org/?template=play-tsc&id=hhPr9s . The highlight color is changed to white.
semocodev commentedon Nov 8, 2019
Issue related nested routing on BottomNavigation using nativescript-angular
Navigation structure according this structure:

When i am trying to navigate from /welcome route to pages/[path] route,
this.routerExtensions.navigate([{ outlets: { homeoutlet: ['pages', 'home'] } }]);i get this error:
Error:
ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'pages/home'Playground example: https://play.nativescript.org/?template=play-ng&id=sVR895&v=3
Angusoft-India commentedon Feb 11, 2020
@smorcuend
The
path:''shouldn't be empty when you use named outlet in yourpages-routing.module.ts.Just try
path:'default'to have the outlet find theactiveRoute.Thanks
jessorlisa commentedon Nov 4, 2020
Just curios, is someone still working on the open issues? Or is the list outdated?
triniwiz commentedon May 12, 2021
@farfromrefug a little something for your plugin 😄
rigor789 commentedon Sep 7, 2023
Closing because BottomNavigation and Tabs are no longer part of core since NativeScript 8.0:
https://blog.nativescript.org/nativescript-8-announcement/#important-note-about-bottomnavigation-and-tabs