In React Native, the Bottom Tab Navigator is a common navigation pattern that allows you to navigate between different screens or tabs using a tab bar at the bottom of the screen. To implement a Bottom Tab Navigator, you can use a library called react-navigation
.

Here’s a basic example of how to set up a Bottom Tab Navigator using react-navigation
:
- Install
react-navigation
andreact-navigation/bottom-tabs
:
npm install @react-navigation/native @react-navigation/bottom-tabs
- Install required dependencies for navigation:
npm install react-native-reanimated react-native-gesture-handler react-native-screens react-native-safe-area-context @react-native-community/masked-view
- Create a navigation file (e.g.,
AppNavigator.js
):
// AppNavigator.js
import React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import Screen1 from './Screen1'; // Import your screen components
import Screen2 from './Screen2';
const Tab = createBottomTabNavigator();
const AppNavigator = () => {
return (
<NavigationContainer>
<Tab.Navigator>
<Tab.Screen name="Screen1" component={Screen1} />
<Tab.Screen name="Screen2" component={Screen2} />
</Tab.Navigator>
</NavigationContainer>
);
};
export default AppNavigator;
- Create your screen components (
Screen1.js
andScreen2.js
):
// Screen1.js
import React from 'react';
import { View, Text } from 'react-native';
const Screen1 = () => {
return (
<View>
<Text>Screen 1</Text>
</View>
);
};
export default Screen1;
// Screen2.js
import React from 'react';
import { View, Text } from 'react-native';
const Screen2 = () => {
return (
<View>
<Text>Screen 2</Text>
</View>
);
};
export default Screen2;
- Import and use your
AppNavigator
in yourindex.js
orApp.js
:
// index.js or App.js
import React from 'react';
import AppNavigator from './AppNavigator';
const App = () => {
return <AppNavigator />;
};
export default App;
Now, when you run your React Native app, you should see a simple bottom tab navigation with two tabs, each corresponding to Screen1
and Screen2
. You can customize the tabs and their appearance according to your requirements by exploring the options provided by the react-navigation
library.
Show Comments