Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to remove background color of active tab in @react-navigation/material-bottom-tabs #3554

Closed
transli opened this issue Dec 26, 2022 · 19 comments
Labels
BottomNavigation question Question related to the library, not an issue

Comments

@transli
Copy link

transli commented Dec 26, 2022

I am using @react-navigation/material-bottom-tabs and I would like to remove background color of active tab. Which props should I use? I tried almost everything from documentation.
JO5j9

@transli transli added the question Question related to the library, not an issue label Dec 26, 2022
@lukewalczak
Copy link
Member

I am using @react-navigation/material-bottom-tabs and I would like to remove background color of active tab. Which props should I use? I tried almost everything from documentation.

Hey @transli I would suggest then checking which theme color is used for a specific element, in your case outline pill. Its background color is theme.colors.secondaryContainer which you should be able to easily override using the theme prop:

theme={{colors: {secondaryContainer: 'transparent'}}}

@mehul2013
Copy link

@lukewalczak
theme={{colors: {secondaryContainer: 'transparent'}}}.This solution is not working. Let me know if any other solution you have.

@lukewalczak
Copy link
Member

Please attach the screenshot with the mark which color you want to change.

@mehul2013
Copy link

mehul2013 commented Jan 3, 2023

@lukewalczak
I want to remove highlighted background color of specific tab. Please see the attachment:
Simulator Screen Shot - iPhone 13 - 2023-01-03 at 20 52 49

@vivekbw
Copy link

vivekbw commented Jan 18, 2023

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

const theme = useTheme();
theme.colors.secondaryContainer = "transperent"

should do the trick

@samkevin1
Copy link

@vivekbw this works, thanks!

@shahnawaz-pabon
Copy link

@vivekbw, Thank you so much. You've rescued me.

@VictorVMHC
Copy link

thanks vivekbw I had been looking for this solution for days

@0xrasla
Copy link

0xrasla commented Apr 28, 2023

@vivekbw Nice thanks for this!

@gabriel-brito
Copy link

@vivekbw life saver!

@ritik2727
Copy link

import { createMaterialBottomTabNavigator } from '@react-navigation/material-bottom-tabs';

const Tab = createMaterialBottomTabNavigator();

// Inside your component
<Tab.Navigator
tabBarOptions={{
activeBackgroundColor: 'transparent', // Set the background color of active tab to transparent
}}

{/* Add your tab screens */}
</Tab.Navigator>

@kholood-ea
Copy link

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

const theme = useTheme();
theme.colors.secondaryContainer = "transperent"

should do the trick

Thank YOU!!

@htthecool
Copy link

{secondaryContainer: 'transparent'}

this worked perfectly, thanks :)

@AjmirSarker
Copy link

@vivekbw thank you for your answer.
Now., I have a problem with tabBarColor, it is not changing after giving different tabBarColor in each screen. Can you suggest any solution, Thanks.

@sheikhshab
Copy link

sheikhshab commented Nov 17, 2023

What if want to change the color of this background?

@AlModutram
Copy link

AlModutram commented Aug 7, 2024

Using these lines:

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

const theme = useTheme();
theme.colors.secondaryContainer = "transperent"`

I'm getting this error:

Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:

  1. You might have mismatching versions of React and the renderer (such as React DOM)
  2. You might be breaking the Rules of Hooks
  3. You might have more than one copy of React in the same app

Also using this:
theme={{colors: {secondaryContainer: 'transparent'}}}
doesn't work.

Please, can you help me!

This is my code:

`import { faBars } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome';
import { createMaterialBottomTabNavigator } from '@react-navigation/material-bottom-tabs';
import * as React from 'react';
import * as colors from '../../../../colors';
import { AppTexts } from '../../../assets/languages/ES/AppTexts';
import { ClearProps } from '../../Props';

const Tab = createMaterialBottomTabNavigator();

export default class BottomAction extends React.Component {
constructor(props: ClearProps) {
super(props);
}

render() {
    return (
        <Tab.Navigator
            activeColor={colors["secondary-03"]}
            inactiveColor={colors["secondary-03"]}
            barStyle={{ backgroundColor: colors["secondary-15"] }}>
            <Tab.Screen
                name={AppTexts.BUTTON_BOTTOM_01}
                component={this.BookingScreen}
                options={{
                    tabBarIcon: ({ color }) => (
                        <FontAwesomeIcon
                            icon={faBars}
                            size={20}
                            color={color} />
                    ),
                }}/>
            <Tab.Screen 
                name={AppTexts.BUTTON_BOTTOM_02} 
                component={this.MyCheckInSceen} 
                options={{
                    tabBarIcon: ({ color }) => (
                        <FontAwesomeIcon
                            icon={faBars}
                            size={20}
                            color={color} />
                    ),
                }}/>
            <Tab.Screen 
                name={AppTexts.BUTTON_BOTTOM_03} 
                component={this.QRCodeScreen} 
                options={{
                    tabBarIcon: ({ color }) => (
                        <FontAwesomeIcon
                            icon={faBars}
                            size={20}
                            color={color} />
                    ),
                }}/>
            <Tab.Screen 
                name={AppTexts.BUTTON_BOTTOM_04} 
                component={this.MyTravelScreen} 
                options={{
                    tabBarIcon: ({ color }) => (
                        <FontAwesomeIcon
                            icon={faBars}
                            size={20}
                            color={color} />
                    ),
                }}/>
        </Tab.Navigator>
    );
}`

@gonsals
Copy link

gonsals commented Oct 17, 2024

Now how can I change the padding of the background pill

@angelilton
Copy link

just for update is the new one to v5
activeIndicatorStyle={{backgroundColor: 'transparent'}}

Image

@Sakib-203-15-3883
Copy link

Thanks, bro , it's work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BottomNavigation question Question related to the library, not an issue
Projects
None yet
Development

No branches or pull requests