Ask Your Question
3

How can vertical padding be added to React Native bottom tabs?

asked 2022-12-26 11:00:00 +0000

plato gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-09-09 03:00:00 +0000

ladyg gravatar image

To add vertical padding to React Native bottom tabs, you can use the tabStyle and labelStyle props in the Tab.Navigator component.

Here is an example code snippet:

import React from 'react';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { Icon } from 'react-native-elements';

const Tab = createBottomTabNavigator();

const MyTabs = () => {
  return (
    <Tab.Navigator
      tabBarOptions={{
        tabStyle: { paddingBottom: 10 },
        labelStyle: { paddingBottom: 5 },
      }}
    >
      <Tab.Screen
        name="Home"
        component={HomeScreen}
        options={{
          tabBarIcon: ({ color, size }) => (
            <Icon name="home" type="font-awesome" color={color} size={size} />
          ),
        }}
      />
      <Tab.Screen
        name="Profile"
        component={ProfileScreen}
        options={{
          tabBarIcon: ({ color, size }) => (
            <Icon
              name="user-circle"
              type="font-awesome"
              color={color}
              size={size}
            />
          ),
        }}
      />
    </Tab.Navigator>
  );
};

export default MyTabs;

In the tabBarOptions prop, we set the tabStyle to have a paddingBottom of 10 and the labelStyle to have a paddingBottom of 5. This will add vertical padding to both the icons and the labels in the bottom tabs. Adjust the values to your desired amount of padding.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-12-26 11:00:00 +0000

Seen: 9 times

Last updated: Sep 09 '22