How to change react native paper bottom navigation active color?
Asked Answered
P

2

7

I want to change the color of react-native-paper naviagation. How can i change the color. I am able to change the color of background but not able to change the color of active tab round button.

Image Link = https://i.sstatic.net/3Edpm.png

I Want to change pink to blue how can I change.

import * as React from 'react';
import { BottomNavigation} from 'react-native-paper';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';


const Tab = createBottomTabNavigator();


const HomePage =({route,navigation})  => {
    const [index, setIndex] = React.useState(0);
    const [routes] = React.useState([
        { key: 'home', title: 'Home', focusedIcon: 'home', unfocusedIcon : 'home-outline',  },
        { key: 'orderHistory', title: 'Order History', focusedIcon: 'clock', unfocusedIcon: 'clock-outline' },
        { key: 'profile', title: 'Profile', focusedIcon: 'account', unfocusedIcon : 'account-outline'},
        { key: 'other', title: 'Other', focusedIcon: 'dots-horizontal-circle', unfocusedIcon: 'dots-horizontal-circle-outline' },
    ]);
    const renderScene = BottomNavigation.SceneMap({
        profile: ProfileBase,
        home: HomeBase,
        orderHistory: OrderHistoryBase,
        other: OtherBase,
    });

    return (
        <View style={{backgroundColor: "white", height: '100%'}}>
            <BottomNavigation
                shifting={false}
                variant='secondary'
                navigationState={{ index, routes }}
                onIndexChange={setIndex}
                renderScene={renderScene}
                barStyle={{backgroundColor:'white'}}
                />
        </View>
    );
}

export default HomePage;

// activeColor="red"
// barStyle={{ backgroundColor: '#1fa9e8'  }}
Polenta answered 16/10, 2022 at 17:13 Comment(0)
M
4

you have to override the secondaryContainer color, locally in the component via theme prop: https://github.com/callstack/react-native-paper/issues/3248

 <BottomNavigation
      ...
      theme={{colors: {secondaryContainer: 'yellow'}}}
    />
Magnitogorsk answered 14/11, 2022 at 15:55 Comment(0)
B
5

In react native paper theme object just change secondaryContainer color

const theme = {
  ...DefaultTheme,
  colors: {
    ...DefaultTheme.colors,
    primary: "#3498db",
    secondary: "#f1c40f",
    secondaryContainer: "red",
  },
};
Bendite answered 9/11, 2022 at 15:26 Comment(0)
M
4

you have to override the secondaryContainer color, locally in the component via theme prop: https://github.com/callstack/react-native-paper/issues/3248

 <BottomNavigation
      ...
      theme={{colors: {secondaryContainer: 'yellow'}}}
    />
Magnitogorsk answered 14/11, 2022 at 15:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.