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.
Asked: 2022-12-26 11:00:00 +0000
Seen: 9 times
Last updated: Sep 09 '22