1

I'm using @react-navigation/bottom-tabs Package. But I don't know how to change background color of the tab bar. Here is my Code.

import React from "react";
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import Home from "./TabScreen/Home";
import Category from "./TabScreen/Category";
import Search from "./TabScreen/Search";
import Profile from "./TabScreen/Profile";
import Colors from "../../../Style_Sheet/Colors";

const Tab = createBottomTabNavigator();

const Tabs =()=>{
  return(
    <Tab.Navigator tabBarPosition="bottom" barStyle={{ backgroundColor: '#0000' }}>
      <Tab.Screen name="Home" component={Home} options={{headerTitle:"Explore",headerTintColor:Colors.white,}}/>
      <Tab.Screen name="Category" component={Category} />
      <Tab.Screen name="Search" component={Search} />
      <Tab.Screen name="Profile" component={Profile} />

    </Tab.Navigator>
  )
}
export default Tabs;

I am adding under then Tab.Navigator tag but it's not working.

Talha Akbar
  • 462
  • 3
  • 15

3 Answers3

1

For version 6 you have to add screenOptions like this in Tab.Navigator

<Tab.Navigator
  screenOptions={{
    tabBarStyle: {
      backgroundColor: '#000',
    },
  }}>
</Tab.Navigator>
MUHAMMAD ILYAS
  • 1,402
  • 7
  • 23
Saral Karki
  • 4,530
  • 2
  • 7
  • 10
1

If

<Tab.Navigator 
screenOptions={{
        tabBarStyle: {
          backgroundColor: '#fff',
        },
      }}>
</Tab.Navigator>

not working then change the Theme Color, The below code will work when assigning border-radius and can't change the background color enter image description here

1.import {NavigationContainer, DefaultTheme} from '@react-navigation/native';

2.

const MyTheme = {
  ...DefaultTheme,
  colors: {
    ...DefaultTheme.colors,
    background: '#fff',
  },
};
  1. <NavigationContainer theme={MyTheme}>
Salman
  • 191
  • 9
0

<Tab.Navigator screenOptions={{ tabBarActiveTintColor: '#000000', tabBarLabelStyle: { fontSize: 14, textTransform: 'capitalize', fontFamily:'Poppins-Regular'}, tabBarStyle: { backgroundColor: '#FAFAFA' }, tabBarUnderlineStyle: { backgroundColor: 'red' }, }} // tabBar={NavRenderer} >

  • 1
    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 Jul 18 '23 at 22:39