Contents
Here is an example of React Native Bottom Navigation for Android and IOS using React Navigation V5. Bottom Navigation is very useful when you have 2-3 main navigation options. It provides the user with easy access to regular usable options.
This example is updated for the React Navigation V5. For the React Navigation V4, you can scroll to the bottom.
In this example, We will make a Bottom Navigation with navigation options like Home and Setting. Each screen has other navigation options too. So let’s get started.
To Make a React Native App
Getting started with React Native will help you to know more about the way you can make a React Native project. We are going to use react-native init to make our React Native App. Assuming that you have node installed, you can use npm to install the react-native-cli
command line utility. Open the terminal and go to the workspace and run
npm install -g react-native-cli
Run the following commands to create a new React Native project
react-native init ProjectName
If you want to start a new project with a specific React Native version, you can use the --version argument:
react-native init ProjectName --version X.XX.X
react-native init ProjectName --version react-native@next
This will make a project structure with an index file named App.js in your project directory.
Installation of Dependencies
For React Native Bottom Navigation we need to add react-navigation
and other supporting dependencies.
To install the dependencies open the terminal and jump into your project
cd ProjectName
1. Install react-navigation
npm install @react-navigation/native --save
2. Other supporting libraries react-native-gesture-handler
, react-native-reanimated
, react-native-screens
and react-native-safe-area-context
and @react-native-community/masked-view
npm install react-native-reanimated react-native-gesture-handler react-native-screens react-native-safe-area-context @react-native-community/masked-view --save
3. For the Bottom Navigator install
npm install @react-navigation/bottom-tabs --save
4. We are going to use MaterialCommunityIcons
to show the menu icons from react-native-vector-icons/MaterialCommunityIcons
. To install react-native-vector-icons
npm install react-native-vector-icons --save
Please visit Example to Use React Native Vector Icons for further instructions to complete the installation of Vector Icons.
5. These steps are enough for the bottom navigation but in this example, we are also using between screens so we will also need Stack Navigator
npm install @react-navigation/stack --save
Note: When you use a navigator, you’ll need to follow the installation instructions of that navigator for any additional dependencies. If you’re getting an error “Unable to resolve module”, you need to install that module in your project.
You might get warnings related to peer dependencies after installation. They are usually caused by incorrect version ranges specified in some packages. You can safely ignore most warnings as long as your app builds.
CocoaPods Installation
Please use the following command to install CocoaPods
cd ios && pod install && cd ..
To finalize the installation of react-native-gesture-handler
, add the following at the top (make sure it’s at the top and there’s nothing else before it) of your entry files, such as index.js or App.js:
import 'react-native-gesture-handler';
Note: If you skip this step, your app may crash in production even if it works fine in development.
Project File Structure
To start with this Example you need to create a directory named pages in your project and create four files DetailsScreen.js, HomeScreen.js, ProfileScreen.js, and SettingScreen.js in it.


App.js
Open App.js in any code editor and replace the code with the following code.
// React Native Bottom Navigation
// https://aboutreact.com/react-native-bottom-navigation/
import 'react-native-gesture-handler';
import * as React from 'react';
import
MaterialCommunityIcons
from 'react-native-vector-icons/MaterialCommunityIcons';
import {
NavigationContainer
} from '@react-navigation/native';
import {
createStackNavigator
} from '@react-navigation/stack';
import {
createBottomTabNavigator
} from '@react-navigation/bottom-tabs';
import HomeScreen from './pages/HomeScreen';
import DetailsScreen from './pages/DetailsScreen';
import ProfileScreen from './pages/ProfileScreen';
import SettingsScreen from './pages/SettingsScreen';
const Stack = createStackNavigator();
const Tab = createBottomTabNavigator();
function HomeStack() {
return (
<Stack.Navigator
initialRouteName="Home"
screenOptions={{
headerStyle: { backgroundColor: '#42f44b' },
headerTintColor: '#fff',
headerTitleStyle: { fontWeight: 'bold' }
}}>
<Stack.Screen
name="Home"
component={HomeScreen}
options={{ title: 'Home Page' }}/>
<Stack.Screen
name="Details"
component={DetailsScreen}
options={{ title: 'Details Page' }} />
</Stack.Navigator>
);
}
function SettingsStack() {
return (
<Stack.Navigator
initialRouteName="Settings"
screenOptions={{
headerStyle: { backgroundColor: '#42f44b' },
headerTintColor: '#fff',
headerTitleStyle: { fontWeight: 'bold' }
}}>
<Stack.Screen
name="Settings"
component={SettingsScreen}
options={{ title: 'Setting Page' }}/>
<Stack.Screen
name="Details"
component={DetailsScreen}
options={{ title: 'Details Page' }}/>
<Stack.Screen
name="Profile"
component={ProfileScreen}
options={{ title: 'Profile Page' }}/>
</Stack.Navigator>
);
}
function App() {
return (
<NavigationContainer>
<Tab.Navigator
initialRouteName="Feed"
tabBarOptions={{
activeTintColor: '#42f44b',
}}>
<Tab.Screen
name="HomeStack"
component={HomeStack}
options={{
tabBarLabel: 'Home',
tabBarIcon: ({ color, size }) => (
<MaterialCommunityIcons
name="home"
color={color}
size={size}
/>
),
}} />
<Tab.Screen
name="SettingsStack"
component={SettingsStack}
options={{
tabBarLabel: 'Settings',
tabBarIcon: ({ color, size }) => (
<MaterialCommunityIcons
name="settings"
color={color}
size={size}
/>
),
}} />
</Tab.Navigator>
</NavigationContainer>
);
}
export default App;
HomeScreen.js
Open pages/HomeScreen.js in any code editor and place the following code.
// React Native Bottom Navigation
// https://aboutreact.com/react-native-bottom-navigation/
import * as React from 'react';
import {
TouchableOpacity,
StyleSheet,
View,
Text,
SafeAreaView
} from 'react-native';
const HomeScreen = ({ navigation }) => {
return (
<SafeAreaView style={{ flex: 1 }}>
<View style={{ flex: 1, padding: 16 }}>
<View
style={{
flex: 1,
alignItems: 'center',
justifyContent: 'center',
}}>
<Text
style={{
fontSize: 25,
textAlign: 'center',
marginBottom: 16
}}>
You are on Home Screen
</Text>
<TouchableOpacity
style={styles.button}
onPress={
() => navigation.navigate(
'SettingsStack', { screen: 'Settings' }
)}>
<Text>Go to settng Tab</Text>
</TouchableOpacity>
<TouchableOpacity
style={styles.button}
onPress={
() => navigation.navigate('Details')
}>
<Text>Open Details Screen</Text>
</TouchableOpacity>
</View>
<Text
style={{
fontSize: 18,
textAlign: 'center',
color: 'grey'
}}>
React Native Bottom Navigation
</Text>
<Text
style={{
fontSize: 16,
textAlign: 'center',
color: 'grey'
}}>
www.aboutreact.com
</Text>
</View>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
button: {
alignItems: 'center',
backgroundColor: '#DDDDDD',
padding: 10,
width: 300,
marginTop: 16,
},
});
export default HomeScreen;
DetailsScreen.js
Open pages/DetailsScreen.js in any code editor and place the following code.
// React Native Bottom Navigation
// https://aboutreact.com/react-native-bottom-navigation/
import * as React from 'react';
import { View, Text, SafeAreaView } from 'react-native';
const DetailsScreen = () => {
return (
<SafeAreaView style={{ flex: 1 }}>
<View style={{ flex: 1 , padding: 16}}>
<View
style={{
flex: 1,
alignItems: 'center',
justifyContent: 'center',
}}>
<Text
style={{
fontSize: 25,
textAlign: 'center',
marginBottom: 16
}}>
You are on Details Screen
</Text>
</View>
<Text
style={{
fontSize: 18,
textAlign: 'center',
color: 'grey'
}}>
React Native Bottom Navigation
</Text>
<Text
style={{
fontSize: 16,
textAlign: 'center',
color: 'grey'
}}>
www.aboutreact.com
</Text>
</View>
</SafeAreaView>
);
}
export default DetailsScreen;
ProfileScreen.js
Open pages/ProfileScreen.js in any code editor and place the following code.
// React Native Bottom Navigation
// https://aboutreact.com/react-native-bottom-navigation/
import * as React from 'react';
import { View, Text, SafeAreaView } from 'react-native';
const ProfileScreen = () => {
return (
<SafeAreaView style={{ flex: 1 }}>
<View style={{ flex: 1, padding: 16 }}>
<View
style={{
flex: 1,
alignItems: 'center',
justifyContent: 'center',
}}>
<Text
style={{
fontSize: 25,
textAlign: 'center',
marginBottom: 16
}}>
You are on Profile Screen
</Text>
</View>
<Text
style={{
fontSize: 18,
textAlign: 'center',
color: 'grey'
}}>
React Native Bottom Navigation
</Text>
<Text
style={{
fontSize: 16,
textAlign: 'center',
color: 'grey'
}}>
www.aboutreact.com
</Text>
</View>
</SafeAreaView>
);
}
export default ProfileScreen;
SettingsScreen.js
Open pages/SettingsScreen.js in any code editor and place the following code.
// React Native Bottom Navigation
// https://aboutreact.com/react-native-bottom-navigation/
import * as React from 'react';
import {
TouchableOpacity,
StyleSheet,
View,
Text,
SafeAreaView
} from 'react-native';
const SettingsScreen = ({ route, navigation }) => {
return (
<SafeAreaView style={{ flex: 1 }}>
<View style={{ flex: 1, padding: 16 }}>
<View
style={{
flex: 1,
alignItems: 'center',
justifyContent: 'center',
}}>
<Text
style={{
fontSize: 25,
textAlign: 'center',
marginBottom: 16
}}>
You are on Setting Screen
</Text>
<TouchableOpacity
style={styles.button}
onPress={
() => navigation.navigate('Home')
}>
<Text>Go to Home Tab</Text>
</TouchableOpacity>
<TouchableOpacity
style={styles.button}
onPress={
() => navigation.navigate('Details')
}>
<Text>Open Detail Screen</Text>
</TouchableOpacity>
<TouchableOpacity
style={styles.button}
onPress={
() => navigation.navigate('Profile')
}>
<Text>Open Profile Screen</Text>
</TouchableOpacity>
</View>
<Text
style={{
fontSize: 18,
textAlign: 'center',
color: 'grey'
}}>
React Native Bottom Navigation
</Text>
<Text
style={{
fontSize: 16,
textAlign: 'center',
color: 'grey'
}}>
www.aboutreact.com
</Text>
</View>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
button: {
alignItems: 'center',
backgroundColor: '#DDDDDD',
padding: 10,
width: 300,
marginTop: 16,
},
});
export default SettingsScreen;
To Run the React Native App
Open the terminal again and jump into your project using.
cd ProjectName
To run the project on an Android Virtual Device or on real debugging device
react-native run-android
or on the iOS Simulator by running (macOS only)
react-native run-ios
Output Screenshots
In this example, we have used MaterialCommunityIcons
for the bottom navigation tab icons. If you want to use the icons from the local directory of your project then please visit our next post on Bottom Navigation with Navigation Icon from Local Directory. This will be a similar example but the bottom tab icon will be from the project’s local directory.
Output in Online Emulator
That was the React Native Bottom Navigation for Android and IOS using React Navigation V5. If you have any doubts or you want to share something about the topic you can comment below or contact us here. There will be more posts coming soon. Stay tuned!
I hope you liked it. 🙂
If you are starting a new app or learning for the first time you should follow V5 steps to create Bottom Navigation but if you are still developing the application using React Navigation V4 then you can follow the below steps.
Installation of Dependencies
Please run following commands in your project directory to install the dependencies
npm install react-navigation --save
npm install react-native-gesture-handler react-native-safe-area-context @react-native-community/masked-view react-native-screens react-native-reanimated --save
npm install react-navigation-tabs --save
npm install react-navigation-stack --save
npm install react-native-vector-icons --save
react-native link react-native-vector-icons
cd ios && pod install && cd ..
Code
App.js
//This is an example code for Bottom Navigation//
import React from 'react';
import {
Button,
Text,
View,
TouchableOpacity,
StyleSheet
} from 'react-native';
//import all the basic component we have used
import Ionicons from 'react-native-vector-icons/Ionicons';
//import Ionicons to show the icon for bottom options
//import React Navigation
import {createAppContainer} from 'react-navigation';
import {createBottomTabNavigator} from 'react-navigation-tabs';
import {createStackNavigator} from 'react-navigation-stack';
import HomeScreen from './pages/HomeScreen';
import SettingsScreen from './pages/SettingsScreen';
import DetailsScreen from './pages/DetailsScreen';
import ProfileScreen from './pages/ProfileScreen';
const HomeStack = createStackNavigator(
{
//Defination of Navigaton from home screen
Home: { screen: HomeScreen },
Details: { screen: DetailsScreen },
},
{
defaultNavigationOptions: {
//Header customization of the perticular Screen
headerStyle: {
backgroundColor: '#42f44b',
},
headerTintColor: '#FFFFFF',
title: 'Home',
//Header title
},
}
);
const SettingsStack = createStackNavigator(
{
//Defination of Navigaton from setting screen
Settings: { screen: SettingsScreen },
Details: { screen: DetailsScreen },
Profile: { screen: ProfileScreen },
},
{
defaultNavigationOptions: {
//Header customization of the perticular Screen
headerStyle: {
backgroundColor: '#42f44b',
},
headerTintColor: '#FFFFFF',
title: 'Settings',
//Header title
},
}
);
const App = createBottomTabNavigator(
{
Home: { screen: HomeStack },
Settings: { screen: SettingsStack },
},
{
defaultNavigationOptions: ({ navigation }) => ({
tabBarIcon: ({ focused, horizontal, tintColor }) => {
const { routeName } = navigation.state;
let IconComponent = Ionicons;
let iconName;
if (routeName === 'Home') {
iconName = `ios-information-circle${focused ?
'' : '-outline'
}`;
} else if (routeName === 'Settings') {
iconName = `ios-checkmark-circle${focused ?
'' : '-outline'
}`;
}
return <IconComponent
name={iconName}
size={25}
color={tintColor}
/>;
},
}),
tabBarOptions: {
activeTintColor: '#42f44b',
inactiveTintColor: 'gray',
},
}
);
export default createAppContainer(App);
pages/HomeScreen.js
//This is an example code for Bottom Navigation//
import React from 'react';
//import react in our code.
import {
Text,
View,
TouchableOpacity,
StyleSheet
} from 'react-native';
//import all the basic component we have used
export default class HomeScreen extends React.Component {
//Home Screen to show in Home Option
render() {
return (
<View
style={{
flex: 1,
justifyContent: 'center',
alignItems: 'center'
}}>
<Text
style={{
marginTop: 50,
fontSize: 25
}}>Home!</Text>
<View
style={{
flex: 1,
justifyContent: 'center',
alignItems: 'center'
}}>
<TouchableOpacity
style={styles.button}
onPress={
() => this.props.navigation.navigate('Settings')
}>
<Text>Go to settng Tab</Text>
</TouchableOpacity>
<TouchableOpacity
style={styles.button}
onPress={
() => this.props.navigation.navigate('Details')
}>
<Text>Open Details Screen</Text>
</TouchableOpacity>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
button: {
alignItems: 'center',
backgroundColor: '#DDDDDD',
padding: 10,
width: 300,
marginTop: 16,
},
});
pages/DetailsScreen.js
//This is an example code for Bottom Navigation//
import React from 'react';
//import react in our code.
import {
Text,
View,
TouchableOpacity,
StyleSheet
} from 'react-native';
//import all the basic component we have used
export default class DetailsScreen extends React.Component {
//Detail Screen to show from any Open detail button
render() {
return (
<View
style={{
flex: 1,
justifyContent: 'center',
alignItems: 'center'
}}>
<Text>Details!</Text>
</View>
);
}
}
pages/ProfileScreen.js
//This is an example code for Bottom Navigation//
import React from 'react';
//import react in our code.
import {
Text,
View,
TouchableOpacity,
StyleSheet
} from 'react-native';
//import all the basic component we have used
export default class ProfileScreen extends React.Component {
//Profile Screen to show from Open profile button
render() {
return (
<View
style={{
flex: 1,
justifyContent: 'center',
alignItems: 'center'
}}>
<Text>Profile!</Text>
</View>
);
}
}
pages/SettingsScreen.js
//This is an example code for Bottom Navigation//
import React from 'react';
//import react in our code.
import {
Text,
View,
TouchableOpacity,
StyleSheet
} from 'react-native';
//import all the basic component we have used
export default class SettingsScreen extends React.Component {
//Setting Screen to show in Setting Option
render() {
return (
<View
style={{
flex: 1,
justifyContent: 'center',
alignItems: 'center'
}}>
<Text
style={{
marginTop: 50,
fontSize: 25
}}>
Setting!
</Text>
<View
style={{
flex: 1,
justifyContent: 'center',
alignItems: 'center'
}}>
<TouchableOpacity
style={styles.button}
onPress={
() => this.props.navigation.navigate('Home')
}>
<Text>Go to Home Tab</Text>
</TouchableOpacity>
<TouchableOpacity
style={styles.button}
onPress={
() => this.props.navigation.navigate('Details')
}>
<Text>Open Detail Screen</Text>
</TouchableOpacity>
<TouchableOpacity
style={styles.button}
onPress={
() => this.props.navigation.navigate('Profile')
}>
<Text>Open Profile Screen</Text>
</TouchableOpacity>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
button: {
alignItems: 'center',
backgroundColor: '#DDDDDD',
padding: 10,
width: 300,
marginTop: 16,
},
});
React Navigation V5 update brings lots of changes in terms of performance and structure. I will suggest you switch to V5 if you are on V4.
Please how to home page diffrent 2 button click go to diffrent bottom tab bar example add please ….
Hello Nilesh,
you can download the project files from here.
https://we.tl/t-mKYf3nIAcL
You can also see the snack here
https://snack.expo.io/SJjbtF-xE?session_id=snack-session–mKzbXCcE
Process:
1. You just need to make a React Native project.
2. Replace app.js and place pages folder from the downloaded files.
3. Add the react-navigation in the project (This Example will help you https://aboutreact.com/react-native-navigation-router/).
and RUN the project.
Hello, how do I put a floating action button on the tab navigation?
There is not a way to put a floating action button on a single place instead you have to make a different component for that and have to include that component into all screens.
I am new to React Native. After seeing your tutorial, I gained so much knowledge. Great Tutorial sir.
Welcome, Nice to hear that 🙂
I was looking for!!!! THNKS A LOT DUDE!!!!
Welcome 🙂
I will add this now thank you!
Welcome 🙂
thx a lot for shareing
hello! thank you for your tutorial!
but do you know how to remove top navbar?)
You can see 3 Ways to Hide Navigation Bar in React Native Application