SwipeUI
ComponentsNavigation

Tab bars

How SwipeUI tab bars plug into Expo Router and React Navigation, and the free core every bar is built on.

Every SwipeUI tab bar is a custom tabBar for Expo Router's Tabs and React Navigation's bottom tabs. Pass it the navigator's props and keep your screens, icons and badges as they are:

app/(tabs)/_layout.tsx
<Tabs tabBar={(props) => <TabBarBasic {...props} />} />

// React Navigation
<Tab.Navigator tabBar={(props) => <TabBarBasic {...props} />} />

Import Tabs from expo-router/js-tabs (importing it from expo-router is deprecated in SDK 57 and 58).

The bars

What every bar does

  • Reads your screen options: tabBarLabel (or title, or the route name), tabBarIcon, tabBarBadge, tabBarAccessibilityLabel, tabBarButtonTestID and tabBarShowLabel. Icons receive the tab-active or tab-inactive colour.
  • Behaves like the built-in bars: a press emits tabPress (listeners can prevent it), then switches tab; a long press emits tabLongPress.
  • Hides when it should: while the keyboard is open (a screen's tabBarHideOnKeyboard: false keeps it), and when the focused screen sets tabBarStyle: { display: 'none' }.
  • Pads for the device: the navigator's safe-area insets, so the home indicator and Android's gesture bar never cover a tab.
  • Accessible: a tab list of tabs with selected states, badges read with the label ("Inbox, 3 new"), 44pt targets and labels capped at 1.4× Dynamic Type.
  • Haptics: a selection tick when the tab changes, never on reselecting. Pass haptics={false} to turn it off.

Building your own bar

tab-bar-core is the free, headless model behind every bar. It's installed with any bar, or on its own:

npx @swipeui/cli add tab-bar-core
components/my-tab-bar.tsx
import { Pressable, Text, View } from 'react-native';
import { useTabBar } from '@/components/swipeui/tab-bar/use-tab-bar';
import type { TabBarProps } from '@/components/swipeui/tab-bar/use-tab-bar';

export function MyTabBar(props: TabBarProps) {
  const { items, hidden, insets, containerProps } = useTabBar(props);
  if (hidden) return null;
  return (
    <View {...containerProps} className="flex-row bg-surface" style={{ paddingBottom: insets.bottom }}>
      {items.map((item) => (
        <Pressable key={item.key} {...item.accessibility} onPress={item.onPress} className="flex-1 items-center p-2">
          <Text className={item.isFocused ? 'text-tab-active' : 'text-tab-inactive'}>{item.label}</Text>
        </Pressable>
      ))}
    </View>
  );
}

TabBarProps accepts both navigators' props: Expo Router 58 passes emitter and navigateToTab, React Navigation 7 passes navigation, and the hook handles either.

PropTypeDefaultDescription
No props of its own.

Minimise on scroll

TabBarScrollProvider shares scroll position between screens and a bar. Wrap the navigator, give each scrolling screen useTabBarScrollHandler(), and read useTabBarMinimizeProgress() (0 expanded, 1 minimised) in a bar. Everything runs on the UI thread, and Reduce Motion makes the change instant. The bottom accessory uses it to shrink on custom bars; native tabs minimise on their own.

Icons with badges

tab-bar-icon draws a tab's icon with its badge at the top-end corner, counts above 99 shown as "99+". Every SwipeUI bar uses it.

On this page