Skip to content

TabBar: the pinned tab bar ​

TabBar is the pinned tab strip that sits under the collapsing header. The default strip: labels with an underline that tracks the finger during a swipe. Scrolls when the tabs overflow. Used by CollapsibleTabView unless you pass renderTabBar; configure it through tabBarProps, or render it yourself from a custom renderTabBar.

tsx
import { TabBar } from 'react-native-collapsible-tabs-native';

renderTabBar={({ routes, index, onIndexChange }) => (
  <View>
    <TabBar routes={routes} index={index} onIndexChange={onIndexChange} scrollEnabled={false} />
    <FilterRow />
  </View>
)}
proptypenotes
routesRoute[]{ key, title }
indexnumberthe active tab
onIndexChange(index) => voidtab pressed
onTabPress(route, index) => voidcalled before onIndexChange, also on the active tab
activeColorstringdefault #111111
inactiveColorstringdefault #8A8A8E
indicatorColorstringdefault #111111
backgroundColorstringdefault #FFFFFF
style / tabStyle / labelStylestylesthe strip, each tab, each label
scrollEnabledbooleandefault true; pass false for equal-width tabs that fill the strip
positionAnimated.Valuethe pager's continuous position (1.4 = 40 % of the way from tab 1 to tab 2) so the underline and label colour track the finger. CollapsibleTabView supplies it; from a custom renderTabBar, feed one from onPageScroll. Without it the strip eases to index on settle

The label colour and underline width interpolate per tab from position, so during a swipe the outgoing underline shrinks as the incoming one grows, in step with the finger.

Released under the MIT License.