react-native-collapsible-tab-view icon indicating copy to clipboard operation
react-native-collapsible-tab-view copied to clipboard

Tab text is not centered

Open michelletaing opened this issue 1 year ago • 2 comments

Hello,

I copied and pasted the code from the quick start example, and the tab bar looks like this:

Image

Why is the tab text not centered with the indicator? I've tried a million different styling things, but I can't seem to get it centered.

(I am using expo)

michelletaing avatar Apr 04 '25 16:04 michelletaing

@michelletaing

You can render a custom tab bar by using MaterialTabBar as the base, then pass MaterialTabItem as the TabItemComponent. Inside MaterialTabItem, you can build your own label like this:

<MaterialTabItem
  {...tabItemProps}
  label={({ name }) => {
    const Icon = name === 'A' ? AnchorIcon : StarIcon;

    return (
      <TouchableOpacity
        style={{ width: window.width / props.tabNames.length }}
        onPress={() => tabItemProps.onPress(name)}>
        <Icon className="text-foreground" width={24} height={24} />
      </TouchableOpacity>
    );
  }}
/>

devnaumov avatar May 03 '25 11:05 devnaumov

Not sure what's going on with MaterialTabBar, but I fixed this issue with the following:

<MaterialTabBar
    labelStyle={{
        margin: 0,
        textAlign: 'center',
        width: <screen_width> / <tab_count>
    }}
/>

mbrzuzy avatar May 27 '25 02:05 mbrzuzy