Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React native activeBackgroundColor/activeTintColor for custom sidebar

I'm calling custom sidebar inside DrawerNavigator. I'm trying to set active tint color and active background color for selected menu.

const DrawerStack = DrawerNavigator(
{
    ProfileScreen: { screen: ProfileScreen },
    Home: { screen: DashboardScreen },
}, 
{
    contentOptions: {
      activeTintColor: "#e91e63",
      activeBackgroundColor : 'purple',
    },
    gesturesEnabled: false,
    swipeEnabled: false,
    contentComponent: SideDrawer
});
like image 832
Gourav Kumar Avatar asked Feb 05 '26 22:02

Gourav Kumar


1 Answers

1) Pass props to SideDrawer.

2) Use props.navigation.state.routes[props.navigation.state.index].routeName to detect the current route in SideDrawer and apply styles accordingly.

like image 104
Tanvir Rahman Avatar answered Feb 09 '26 07:02

Tanvir Rahman