22

I created a simple tab navigation for a React Native app using react-navigation. It works fine, but I can't seem to adjust the height of it. It'll only go to a max of about 80, I need it to be about 150% of the current height, maybe double.

Does anyone know how to increase the height of the tab nav (preferably without creating about 6 more js files? ) I only have a limited period to fix it as I'd like.

Below is the nav code as-is

import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { createBottomTabNavigator, createAppContainer } from "react-navigation";

import HomeScreen from './screens/HomeScreen';
import AboutScreen from './screens/AboutScreen';
import SettingsScreen from './screens/SettingsScreen';


export default class App extends React.Component {
  render() {
    return <AppContainer />;
  }
}

const AppNavigator = createBottomTabNavigator({
  Home: {
    screen: HomeScreen
  },
  About: {
    screen: AboutScreen
  },
  Settings: {
    screen: SettingsScreen
  }
}, {
  initialRouteName: "Home"
});

const AppContainer = createAppContainer(AppNavigator);

Thanks

EricSchaefer
  • 25,272
  • 21
  • 67
  • 103
Rachel Gallen
  • 27,943
  • 21
  • 72
  • 81

6 Answers6

59

As said in the docs, you just need to add screenOptions={tabBarStyle:{height:100}}

For example:

bottomNavigatorConfigs = {
    initialRouteName: "HomeScreen",
    screenOptions: {
        tabBarStyle: { height: 300 },
    },
};

This is an example of the bottomNavigatorConfigs (tested) and working.

Where bottomNavigatorConfigs is used like this:

createBottomTabNavigator(bottomRoutesConfig, bottomNavigatorConfigs);

Source: https://reactnavigation.org/docs/bottom-tab-navigator/#options

F1nn-T
  • 67
  • 8
Auticcat
  • 4,359
  • 2
  • 13
  • 28
  • 1
    In react-navigation v5+ the `screenOptions.tabBarStyle` does not work but only `tabBarOptions.style` does. – Arvind K. Mar 05 '22 at 05:02
  • @ArvindK. I haven't used react-native for a while and don't have an environment to test the new react-navigation features so i can't give an answer for other react-native versions – Auticcat Apr 05 '22 at 07:29
  • Despite @ArvindK. 's comment, `tabBarOptions` appears to have been removed entirely in 6.x , whereas `screenOptions.tabBarStyle` does work. – defraggled Jun 19 '22 at 05:46
23

Be careful with an iPhone's home indicator as you need to take account of the extra space at the bottom of the iPhone when setting absolute height.

import { useSafeAreaInsets } from 'react-native-safe-area-context';
...

export const Navigation = () => {
  const insets = useSafeAreaInsets();
  return (
    <NavigationContainer>
      <Tab.Navigator
        tabBarOptions={{
          style: {
            height: 60 + insets.bottom,
            ...
          },
          tabStyle: {
            height: 60,
            ...
          },
          ...
        }}>
        ...
EricSchaefer
  • 25,272
  • 21
  • 67
  • 103
Shunya Watanabe
  • 340
  • 3
  • 9
  • 2
    In react-navigation v5+ the `screenOptions.tabBarStyle` does not work but only `tabBarOptions.style` does. This answer can be updated for the actual `answer` for v5+ – Arvind K. Mar 05 '22 at 05:03
2

tabBarOptions: { style: { height: '50%', } }

try that may be working.

Ajith
  • 66
  • 1
  • 6
2

With react navigation 6 you can just use:

    tabBarStyle : {
         height: 150,
         ...
    }
Lonare
  • 3,581
  • 1
  • 41
  • 45
1
screenOptions={
  {
    headerShown:false,
    tabBarActiveTintColor:Colors.primary,
    tabBarInactiveTintColor:Colors.primary2,
    tabBarStyle:  { height: 60 }
  } 
}
Nivethan
  • 2,339
  • 19
  • 22
Ali Raza Khan
  • 181
  • 1
  • 4
1
     <Tab.Navigator
       tabBarStyle: {
                      height: 20, 
                     //this increases the height of the 
                       tabNavigation 
                     }
      tabBarLabelStyle: {
                     height:40,
                    //increases height of the label or name 
                      that is below the icon
                         }
      >
Chaitanya
  • 11
  • 2
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 10 '23 at 13:25