PedroBern / react-native-collapsible-tab-view

A cross-platform Collapsible Tab View component for React Native
MIT License
868 stars 171 forks source link

LabelStyle TabBar #289

Open DaylAppReactNative opened 2 years ago

DaylAppReactNative commented 2 years ago

Hi,

I'm trying to change the color of the TabBar text, I tried different styles props including this one :

renderTabBar={props => <MaterialTabBar {...props} labelStyle={{color:"white"}} />}

but for some reason it changes back to black as soon as it finished rendering.

Any advice?

Thank you :)

dearlk commented 2 years ago

hi, I too not able to change any style for tab bar item used all style properties...

TabBarComponent={(props) => <MaterialTabBar {...props} scrollEnabled={true} activeColor="red" inactiveColor="yellow" inactiveOpacity={0.3} labelStyle={{fontSize: 6}} tabStyle={{fontSize: 6}} style={{fontSize: 6}} />}

hazirmagron commented 1 year ago

Did you guys manage to resolve this? I'm having the same issues right now. @dearlk @DaylAppReactNative

bpeck81 commented 1 year ago

I'm having this issue. Is this repo maintained?

andreialecu commented 1 year ago

Cannot look into this without a repro.

Try memoizing renderTabBar. The following works in a project I'm working on:

  const renderTabBar = useCallback(
    (props: TabBarProps) => {
      return (
        <MaterialTabBar
          {...props}
          style={tabBarStyle}
          labelStyle={labelStyle}
          indicatorStyle={indicatorStyle}
          activeColor={colors.text}
          inactiveColor={colors.text}
          scrollEnabled
          keepActiveTabCentered
        />
      );
    },
    [colors.text, indicatorStyle, labelStyle, tabBarStyle],
  );
ipoogleduck commented 6 months ago

This is still an issue for me, even when using memoization as you suggest @andreialecu Here's what I'm doing:

renderTabBar={(props: any) => <MaterialTabBar {...props}
              labelStyle={{ color: 'pink' }}
/>}

The color does not stay pink when switching tabs, it just goes back to the default black color

ipoogleduck commented 6 months ago

Ah I see, activeColor and inactiveColor need to be overridden on the MaterialTabBar