7

In React-Native with React-Navigation I have a Tabnavigator like so:

const testScreenNavigator = TabNavigator({
    Tab1: { screen: Tab1Screen },
    Tab2: { screen: Tab2Screen },
    Tab3: { screen: Tab3Screen },
});
testScreenNavigator.navigationOptions = {
    title: 'MY TITLE',
    header: {
        titleStyle:{
        },
        style:{
// how to set the options?
        },
    }  
}

Now I want to do 2 things:

  1. Set the backgroundColor: 'red' of the Tabs in Android (not iOS bottom tabs)
  2. Have a badge next to Tab1: e.g.

Tab1 (2) | Tab2 | Tab3

Regards

Kishan Vaghela
  • 7,678
  • 5
  • 42
  • 67
user3819370
  • 513
  • 1
  • 6
  • 15

1 Answers1

22
  • Set the backgroundColor for Header and Tab

To set background color for Header use navigationOptions and to set background color for Tab use tabBarOptions. See below code

const testScreenNavigator = TabNavigator ({
  Tab1: { screen: RecentChatsScreen },
  Tab2: { screen: AllContactsScreen },
  Tab3: { screen: AllContactsScreen}
}, {
  tabBarOptions : {
    style: {
      backgroundColor: '#42a5f5',
    }
  }
});

testScreenNavigator.navigationOptions = {
  title: 'MY TITLE',
  header: {
    style: {
      backgroundColor: '#42a5f5',
    }
  },
};

below is output

enter image description here

Kishan Vaghela
  • 7,678
  • 5
  • 42
  • 67