5

How do I change the color of the navigation header in a React Native app?

I tried initialising background color but it didn't work.

Below is my code snippet for navigationOptions:

static navigationOptions = ({ navigation }) => ({
    header: props => <Header 
        navigation={navigation}
        title={'Dashboard'}
        toggleDrawer
    />
})

Also, is it possible to set status bar color?

Roy Wang
  • 11,112
  • 2
  • 21
  • 42
Abhishek D
  • 465
  • 2
  • 9
  • 24

3 Answers3

10

You can change it with headerStyle:

navigationOptions = {
  headerStyle: {
    backgroundColor: 'red',
  },
);

For status bar, see https://facebook.github.io/react-native/docs/statusbar.html

Roy Wang
  • 11,112
  • 2
  • 21
  • 42
0

Use it like this:

static navigationOptions = () => ({
    title: 'Home',
    headerTintColor: '#cccccc',
    headerStyle: {
      backgroundColor: '#000',
    },      
  });
-2

You can use the below parameter to set the status bar color:

<StatusBar backgroundColor='blue' barStyle='light-content' />
Saravanan Sachi
  • 2,572
  • 5
  • 33
  • 42
Sandeep Singh
  • 1,013
  • 1
  • 11
  • 25