Skip to main content
Version: 0.4.0

TabView

The main component for rendering a tab view.

import { TabView } from 'reanimated-tab-view';

Props

TabView extends ViewProps (excluding children) and accepts the following additional props:

Required props

PropTypeDescription
navigationStateNavigationStateThe state of the navigation including the current index and routes. { index: number; routes: Route[] }
onIndexChange(index: number) => voidCallback fired when the active tab index changes.
renderScene(props: SceneRendererProps) => ReactNodeFunction that renders the content for each tab.

Optional props

PropTypeDefaultDescription
initialLayoutobjectundefinedInitial layout dimensions to reduce jitter. See below.
tabBarConfigTabBarConfigundefinedConfiguration for the tab bar. See below.
renderHeader(props: HeaderRendererProps) => ReactNodeundefinedRenders a collapsible header above the tab bar.
renderMode'all' | 'windowed' | 'lazy''all'Controls how scenes are rendered.
jumpMode'smooth' | 'scrolling' | 'no-animation''smooth'Controls the animation when jumping between tabs.
swipeEnabledbooleantrueEnables or disables swipe gestures between tabs.
keyboardDismissMode'none' | 'on-drag' | 'auto''auto'How to dismiss the keyboard when swiping.
animatedRouteIndexSharedValue<number>undefinedA shared value that gets updated with the current animated route index.
sceneContainerStyleStyleProp<ViewStyle>undefinedStyle for the scene container.
tabViewCarouselStyleStyleProp<ViewStyle>undefinedStyle for the tab view carousel.
sceneContainerGapnumber0Gap between each scene.
styleStyleProp<ViewStyle>undefinedStyle for the root view.
onSwipeStart() => voidundefinedCallback when a swipe gesture starts.
onSwipeEnd() => voidundefinedCallback when a swipe gesture ends.

initialLayout

Object to provide initial dimensions and reduce layout jitter:

initialLayout?: {
tabView?: Partial<{ width: number; height: number }>;
tabViewHeader?: Partial<{ width: number; height: number }>;
tabBar?: Partial<{ width: number; height: number }>;
}

TabBarConfig

Configuration object for the tab bar, passed via the tabBarConfig prop:

PropTypeDefaultDescription
tabBarPosition'top' | 'bottom''top'Position of the tab bar.
tabBarType'primary' | 'secondary''secondary'Type of tab bar per Material Design spec.
tabBarScrollEnabledbooleantrueEnables scrollable tab bar.
tabBarDynamicWidthEnabledbooleantrue for primary, false for secondaryEnables dynamic tab widths based on title length.
scrollableTabWidthnumber100Width of each tab when tabBarScrollEnabled is true.
tabBarStyleStyleProp<ViewStyle>undefinedStyle for the tab bar container.
tabBarIndicatorStyleStyleProp<ViewStyle>undefinedStyle for the tab indicator.
tabStyleStyleProp<ViewStyle>undefinedStyle for individual tabs.
tabLabelStyleStyleProp<TextStyle>undefinedStyle for tab labels.
renderTabBar(props: TabBarProps) => ReactNodeundefinedCustom tab bar renderer.

Ref methods

Access ref methods by passing a ref to TabView:

const ref = React.useRef<TabViewMethods>(null);

<TabView ref={ref} /* ...props */ />

// Later:
ref.current?.jumpTo('settings');

jumpTo(routeKey: string)

Programmatically jump to a specific tab by its route key. The animation style follows the current jumpMode setting.