react-navigation icon indicating copy to clipboard operation
react-navigation copied to clipboard

Material Top Tab Navigator missing tabBarButton option

Open nelsonchen5 opened this issue 5 years ago • 4 comments

There is currently no tabBarButton under the options prop for createMaterialTopTabNavigator, is there any other way to customize or style the individual tabs on the tab bar (besides label and icon) without recreating an entirely customized TabBar?

nelsonchen5 avatar Jun 03 '20 18:06 nelsonchen5

Hello, @nelsonchen5! If you want to customise appearance of your tabs you can pass tabBarLabel to the options of your screens as a function returning JSX instead of a string. Like that:

{TABS.map(tab => (
  <Tab.Screen
    key={tab.name}
    name={tab.name}
    component={YourComponent}
    options={{
       title: tab.name,
       tabBarLabel: () => (
         <View style={styles.tabBarLabelContainer}>
          <Text>{tab.name}</Text>
          <Text>{/* Some additional info goes here */}</Text>
          {/* Pass any other components here */}
         </View>
       )
    }}
  />
))}

And after that you can additionally customise bottom indicator via tabBarOptions --> indicatorStyle

DnEgorWeb avatar Jun 10 '20 07:06 DnEgorWeb

tabBarButton on the bottom tabs can be configured to dynamically hide a tab. Without exposing tabBarButton here, I haven't found a good way to do it with material top tabs.

seantimm avatar Jul 22 '20 14:07 seantimm

@seantimm that's the exact issue that I'm currently running into

nelsonchen5 avatar Jul 22 '20 21:07 nelsonchen5

could you find any solution? I can't hide a specific tab using Material Top Tab Navigator.

ggchicote avatar Sep 05 '22 17:09 ggchicote