4

I want to remove the Icon space/View from the Bottom tab Navigator. I tried to remove the Icon by removing tabBarIcon but it didn't work. Here is the code I tried and the outcome I received. It is not looking that good, the label is not at the center. They looks like they have gone below the visible screen. Code used:

const TabNavigator = createMaterialBottomTabNavigator(
{
    Home: {
        screen: screen1,
        navigationOptions: {
            // tiitle: "hello"
            // tabBarIcon: () => {
            //     <View></View>
            // },
            tabBarLabel: <Text style={{ fontSize: 15, textDecorationLine: 'underline', }}>Screen1</Text>,
        }
    },
    People: {
        screen: screen2,
        navigationOptions: {
            tabBarLabel: <Text style={{ fontSize: 15, textDecorationLine: 'underline' }}>Screen2</Text>,
            activeColor: '#E8947F',
            inactiveColor: '#C4C9CB',
        }
    },
    Connects: {
        screen: screen3,
        navigationOptions: {
            tabBarLabel: <Text style={{ fontSize: 15, textDecorationLine: 'underline' }}>Screen3</Text>,
            activeColor: '#E8947F',
            inactiveColor: '#C4C9CB',

            // barStyle: { backgroundColor: '#2c6d6a' },
        }
    },
},
{
    initialRouteName: 'Home',
    activeColor: '#E8947F',
    inactiveColor: '#C4C9CB',
    barStyle: { backgroundColor: '#00000000' },
});

Outcome:

enter image description here

I am new to React-Native. Please help me.

Vikas Bansal
  • 2,184
  • 2
  • 15
  • 18

6 Answers6

10

You just have to add screenOptions={{tabBarIconStyle: { display: "none" }}} like below example.

<Tab.Navigator
  screenOptions={{
    tabBarLabelPosition: "beside-icon",
    tabBarLabelStyle: {
      fontWeight: "700",
      fontSize: 15
    },
    tabBarIconStyle: { display: "none" },
  }}
>
  <Tab.Screen
    component={DemoComponent}
    name="Demo"
    options={{ tabBarLabel: "My Demo" }}
  />
</Tab.Navigator>
Vivek S
  • 179
  • 1
  • 2
  • 17
8

Just you need to add this options in Tab.Screen which you want to hide in TabNavigator like below.

<Tab.Screen name="Home" component={HomeStack} options={{
    tabBarButton: () => null,
    tabBarVisible: false,
  }} />
Jemish Rajpara
  • 119
  • 1
  • 3
0

I had the same problem today and I didn't found a single solution in the whole internet.

Fortunately, I managed to solve it with the following styles:

tabBarOptions={{
  labelStyle: {
    position: 'absolute',
    top: 0,
    bottom: 0,
    left: 0,
    right: 0,
    textAlignVertical: 'center',
  },
}}
0

I solved this problem with below tabBarOptions,

tabBarOptions: {
  style: {
    backgroundColor: 'white',
    alignItems: 'center',
  },
  labelStyle: {
    fontSize: 16,
  },
  activeTintColor: '#444444',
  inactiveTintColor: 'lightgrey',
  showIcon: false,
}
SKG
  • 346
  • 4
  • 11
0

For me, worked only

tabBarLabelStyle: {
    position: 'absolute'
}

If you want to see the differences, add borderWith: 1 to make sure

Nikita Skrebets
  • 1,518
  • 2
  • 13
  • 19
-2

Add this to your navigation code:

tabBarOptions: {
    showIcon: false
},

Ref: React Navigation Documentation

Brian H.
  • 1,603
  • 11
  • 16