react-native-material-ui icon indicating copy to clipboard operation
react-native-material-ui copied to clipboard

Unable to set active icon and label style in BottomNavigation.Action

Open jelmarose opened this issue 6 years ago • 7 comments

When using <BottomNavigation.Action />, the only style property working is container. How do I set the style properties of active and disabled?

<BottomNavigation.Action
              key="today"
              icon={<FontAwesome name='bell' size={25} />}
              label="Alerts"
              onPress={() => this.setState({ active: 'alert' })}
              style={{
                container:{
                  backgroundColor: 'red'
                },
                active:{
                  color: '#AC8E49',
                }
              }}
          />

The component rendered has a red background but the icon style is not colored.

jelmarose avatar Oct 14 '18 21:10 jelmarose

I have some problem.

Code :-

<BottomNavigation.Action
          style={{
                active: {
                   color: "green"
                 }
            }}
            key="today"
            icon="today"
            label="Today"
            onPress={() => this.setState({ active: "today" })}
 />

Result :- screenshot 2018-12-11 at 6 31 09 pm

ManishAhire avatar Dec 11 '18 12:12 ManishAhire

hi, active color property is not working for me:-

Code:- <BottomNavigation.Action key="today" icon="today" label="Today" active={this.state.active} onPress={() => this.setState({ active: "today" })} style={{ container: { backgroundColor: "lightblue" }, active: { color: "green" } }} />

Result:- screen shot 2019-02-25 at 11 19 29 am

harikanammi avatar Feb 25 '19 05:02 harikanammi

If you'll check BottomNavigationAction class, you'll see, that active and disabled style properties are not assigned to the label and icon.

BottomNavigation.Action with changing icon and label colors should look like this:

<BottomNavigation.Action
      key="people"
      icon="people"
      label="People"
      style={{
          container: {
               backgroundColor: '#054B81',
           },
          icon: {color: '#FFFFFF'},
          label: {color: '#FFFFFF'},
      }}
      onPress={() => this.setState({active: 'people'})}
/>

Kich-kichi avatar Jun 03 '19 20:06 Kich-kichi

Same problem, any update on this?

dushyanttessact avatar Aug 27 '19 11:08 dushyanttessact

@dushyanttessact, check my reply above.

Kich-kichi avatar Aug 27 '19 11:08 Kich-kichi

@Kich-kichi Hey, thanks for the quick reply. but what i'm looking for is different, i just want to change the icon and label color when active. Like in default view, the color changes white to blue when clicked. will try to update css part onPress fn. might work.

dushyanttessact avatar Aug 27 '19 11:08 dushyanttessact

This works,

<BottomNavigation.Action
                    key="Movies"
                    icon={movieIcon}
                    style={{
                        icon: {color: this.state.activeBottomNavScreen === "Movies" ? "#fdbd32" : "#7ccced"},
                        label: {color: this.state.activeBottomNavScreen === "Movies" ? "#fdbd32" : "#7ccced"},
                    }}
                    label="Movies"
                    onPress={this.setBottomNavScreen.bind(this,"Movies")}
                />

dushyanttessact avatar Aug 27 '19 12:08 dushyanttessact