Closed transli closed 1 year ago
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'}}}
@lukewalczak
theme={{colors: {secondaryContainer: 'transparent'}}}
.This solution is not working. Let me know if any other solution you have.
Please attach the screenshot with the mark which color you want to change.
@lukewalczak I want to remove highlighted background color of specific tab. Please see the attachment:
import { useTheme } from 'react-native-paper';
const theme = useTheme();
theme.colors.secondaryContainer = "transperent"
should do the trick
@vivekbw this works, thanks!
@vivekbw, Thank you so much. You've rescued me.
thanks vivekbw I had been looking for this solution for days
@vivekbw Nice thanks for this!
@vivekbw life saver!
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>
import { useTheme } from 'react-native-paper'; const theme = useTheme(); theme.colors.secondaryContainer = "transperent"
should do the trick
Thank YOU!!
{secondaryContainer: 'transparent'}
this worked perfectly, thanks :)
@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.
What if want to change the color of this background?
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:
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
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>
);
}`
Now how can I change the padding of the background pill
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.