Skip to main content

createTopTabNavigator

Define peer routes with a tab bar above their content.

Import​

import { createTopTabNavigator, createTopTabScreen } from '@bedrock-core/navigation';

Signature​

createTopTabNavigator(config): StaticNavigator<'tab'>

Parameters​

ParameterTypeDefaultDescription
config*TopTabNavigatorConfig—Static tabs, shared options and Back policy

The screens, groups, id, initialRouteName, screenOptions and screenListeners fields follow static screen configuration.

OptionTypeDefaultDescription
backBehaviorTab Back policy'firstRoute'Select a tab or bubble Back to the parent
tabBar(props: TopTabBarProps) => JSX.ElementBuilt-in top barRender a pure custom tab bar

Returns​

A definition passed to createStaticNavigation or nested as another navigator's screen.

Usage​

const Tabs = createTopTabNavigator({
initialRouteName: 'Shop',
backBehavior: 'history',
screens: {
Shop: ShopStack,
Account: createTopTabScreen({
screen: Account,
options: { tabBarLabel: 'Account', tabBarBadge: 2 },
}),
},
});

createTopTabScreen(config) preserves callback parameter inference. A tab containing a stack retains that stack when another tab is selected.

Back behavior​

ValueBehavior
'firstRoute'Select the first declared tab
'initialRoute'Select initialRouteName
'order'Select the preceding tab in declaration order
'history'Return through visited tabs, keeping one history entry per tab
'fullHistory'Return through visits including repeated tab selections
'none'Let the parent or root handle Back

When the tab policy has no previous target, Back bubbles to its parent. The root then applies its configured caller-or-close policy.

Tab appearance​

OptionTypeDefaultDescription
tabBarLabelDisplayTextTitle or route nameCaption in the tab bar
tabBarShowLabelbooleantrueShow the caption
tabBarIcon({ focused, size }) => JSX.Element—Pure icon renderer for compiled focus variants
tabBarBadgestring | number—Badge beside the tab caption

Common header options are also accepted. A custom tabBar receives state, descriptors, scoped navigation, and a declarative actions map keyed by route name. Pass an action to Link to keep native tab selection available.

Notes​

Tab selection can run on the client; it does not call icon renderers or other JavaScript while the form is open. See client navigation for compilation and server boundaries.

The scoped hook adds jumpTo(name, params?). Preventable tabPress listeners require explicit server navigation. Native tab controls do not expose a long-press gesture.