Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove pill shape when active material bottom tabs

Im using @react-navigation/material-bottom-tabs and im experiencing an issue with the icons in the tab navigator. The problem is there is a weird background showing up right behind the icon and the padding is way too big, this is how it looks like:

enter image description here

Im trying to remove the background from the icon but so far no options seem to work.

import { createMaterialBottomTabNavigator } from "@react-navigation/material-bottom-tabs";
import { ColorCodes } from "../helper/palette";
import ViewHome from "../views/home";
import MaterialCommunityIcons from "react-native-vector-icons/MaterialCommunityIcons";

const Tab = createMaterialBottomTabNavigator();

export default function RouteTab() {
  return (
    <Tab.Navigator
      initialRouteName="ViewHome"
      barStyle={{
        backgroundColor: ColorCodes.backgroundDeepest,
      }}
      labeled={false}
      activeColor={ColorCodes.activeColor}
      inactiveColor={ColorCodes.inactiveColor}
    >
      <Tab.Screen
        name="ViewHome"
        component={ViewHome}
        options={{
          tabBarOptions: {
            style: {
              backgroundColor: "blue",
            },
          },
          tabBarLabel: "Home",
          tabBarIcon: ({ color }) => (
            <MaterialCommunityIcons name="home" color={color} size={26} />
          ),
        }}
      />
      <Tab.Screen
        name="qwwqdqwd"
        component={ViewHome}
        options={{
          tabBarLabel: "Home",
          tabBarIcon: ({ color }) => (
            <MaterialCommunityIcons name="home" color={color} size={26} />
          ),
        }}
      />
    </Tab.Navigator>
  );
}
like image 668
hrodric Avatar asked Jun 26 '26 06:06

hrodric


2 Answers

I had the same problem with Material Bottom Tabs Navigator v6.x and solution for me was to add this :

import { useTheme } from 'react-native-paper';

and in my bottom tab component :

const theme = useTheme();

theme.colors.secondaryContainer = "transparent"

Edit :

You can do this using a better way like this :

import {DefaultTheme, Provider as PaperProvider} from 'react-native-paper';

Then you can update the DefaultTheme using destructuration :

const myNavigationTheme = {
  ...DefaultTheme,
  colors: {
    ...DefaultTheme.colors,
    notification: 'rgba(255, 255, 255, 0.5)',
    secondaryContainer: 'transparent',
  },
};

Finally, just wrap your app with the PaperProvider and your updated theme:

<PaperProvider theme={myNavigationTheme}>
  <App />
</PaperProvider>
like image 133
Julien Lamalle Avatar answered Jun 29 '26 02:06

Julien Lamalle


The issue is coming from react-native-paper, You'll need to downgrade this package to version: ^4.12.5.

"react-native-paper": "^4.12.5",

Hope this helps.

like image 45
Relie Essom Avatar answered Jun 29 '26 02:06

Relie Essom



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!