34

Struggling to understand how to change the navigation header bar background color. I'm Using react navigation and Expo to build my app.

backgroundColor does not seem to do anything. Any idea how to do this?

My code is below:

static navigationOptions = () => ({
    title: 'My App',
    headerTintColor: Colors.DarkBlue,
    backgroundColor: 'red',
    headerLeft:
      <HeaderBarItem to='InfoScreen' title='App info' />,
    headerRight:
      <HeaderBarItem to='FeedbackScreen' title='Feedback' />
  });

4 Answers 4

61

This should work:

static navigationOptions = () => ({
    title: 'My App',
    headerTintColor: Colors.DarkBlue,
    headerStyle: {
      backgroundColor: 'red'
    },
    headerLeft:
      <HeaderBarItem to='InfoScreen' title='App info' />,
    headerRight:
      <HeaderBarItem to='FeedbackScreen' title='Feedback' />
  });

2
  • @Aakash where does this Colors.DarkBlue and <HeaderBarItem come from
    – JP.
    Commented Nov 6, 2017 at 19:32
  • 1
    Those are just component and variable from the question @JP Commented Nov 7, 2017 at 4:13
15

I tried many answers throughout the forums but couldn't find the working solution. Finally below worked for me and will for you if you are using latest RN:

export default function App() {

  return (
    <NavigationContainer>
      <Stack.Navigator>
        <Stack.Screen
            name="Home"
            component={Main}
            options={{ title: 'Welcome', headerStyle: {
              backgroundColor: '#e7305b'
           } }}
        />
      </Stack.Navigator>
    </NavigationContainer>
  );
}
1
  • quite explanatory compared to other solutions Commented Aug 25, 2020 at 23:34
12

Paste this in your targeted screen

static navigationOptions = ({ navigation }) => {
   return {
      title: 'Screen Title',
      headerTintColor: 'royalblue',
      headerStyle: {
         backgroundColor: '#fff'
      }
   }
}
0

You can just use inside your view component

<StatusBar backgroundColor = '#fff' />

This worked for me on android

Don't forget to import StatusBar from 'react-native' of course

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.