Skip to content
Tutorials Center
My learning

Topics

Lesson 8 of 38 ยท Expo Router and Navigation

Tabs and Drawer Navigation

Build a bottom tab bar and a side drawer with Expo Router: Tabs layouts, icons, badges, hiding tabs, nested stacks per tab and when to choose tabs or a drawer.

Most apps have a handful of top-level areas: Home, Search, Profile. Tabs put them in a bar at the bottom; a drawer hides them in a side menu. In Expo Router both are just layouts, so you create them with a _layout.tsx file and the files next to it become the tabs.

The navigators need the real runtime, so the app code is read-only. The live stand-ins model how tabs keep one history per tab.

A tab bar

Text
app/
  _layout.tsx             root Stack
  (tabs)/
    _layout.tsx           the Tabs layout
    index.tsx             Home tab
    explore.tsx           Explore tab
    profile.tsx           Profile tab
TSX
// app/(tabs)/_layout.tsx
import { Tabs } from 'expo-router';
import { Ionicons } from '@expo/vector-icons';

export default function TabLayout() {
  return (
    <Tabs screenOptions={{ tabBarActiveTintColor: '#0b5fff', headerShown: true }}>
      <Tabs.Screen
        name="index"
        options={{
          title: 'Home',
          tabBarIcon: ({ color, size }) => <Ionicons name="home" color={color} size={size} />,
        }}
      />
      <Tabs.Screen
        name="explore"
        options={{
          title: 'Explore',
          tabBarIcon: ({ color, size }) => <Ionicons name="compass" color={color} size={size} />,
        }}
      />
      <Tabs.Screen
        name="profile"
        options={{
          title: 'Profile',
          tabBarBadge: 3,
          tabBarIcon: ({ color, size }) => <Ionicons name="person" color={color} size={size} />,
        }}
      />
    </Tabs>
  );
}

The folder is the group (tabs), so the URLs stay /, /explore and /profile. Tabs appear in file order unless you list Tabs.Screen entries in a different order. Common options:

Option Effect
title label and header title
tabBarIcon function returning an icon
tabBarBadge small number/text on the icon
tabBarLabel label different from the header title
tabBarStyle style the bar (height, background)
tabBarShowLabel: false icons only
href: null keep a route inside the tab layout but hide it from the bar
lazy: false mount all tabs immediately instead of on first visit
tabBarButton fully custom tab button

@expo/vector-icons ships with Expo (Ionicons, MaterialIcons, FontAwesome and others), so no extra install is needed. Recent SDKs also offer a native tab bar built on the platform's own components (look for expo-router/unstable-native-tabs in the docs for your SDK); the JavaScript Tabs shown here works everywhere.

Each tab can have its own stack

A tab keeps its own screens. If you need drill-down inside a tab (Explore, then a trail detail), make the tab a folder with its own layout:

Text
app/(tabs)/
  _layout.tsx             Tabs
  index.tsx
  explore/
    _layout.tsx           Stack
    index.tsx             /explore
    [id].tsx              /explore/12
TSX
// app/(tabs)/_layout.tsx
<Tabs>
  <Tabs.Screen name="index" options={{ title: 'Home' }} />
  <Tabs.Screen name="explore" options={{ title: 'Explore', headerShown: false }} />
</Tabs>

Set headerShown: false on the tab so the inner Stack draws the header, otherwise you get two headers. When the user switches tabs and returns, the Explore stack is exactly as they left it.

JS Tabs keep their own history

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Deciding what shows in the bar

Not every route in the tab folder needs a tab. Hide detail routes with href: null:

TSX
<Tabs.Screen name="settings" options={{ href: null }} />

Dynamic badges come from state. The stand-in below shows how a badge value is computed and capped as the UI does ("99+").

JS Badge text

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Drawer navigation

A drawer needs two extra packages: the drawer layout and gesture/animation support.

Terminal
npx expo install @react-navigation/drawer react-native-gesture-handler react-native-reanimated react-native-worklets
TSX
// app/(drawer)/_layout.tsx
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import { Drawer } from 'expo-router/drawer';

export default function DrawerLayout() {
  return (
    <GestureHandlerRootView style={{ flex: 1 }}>
      <Drawer>
        <Drawer.Screen name="index" options={{ drawerLabel: 'Home', title: 'Home' }} />
        <Drawer.Screen name="settings" options={{ drawerLabel: 'Settings', title: 'Settings' }} />
      </Drawer>
    </GestureHandlerRootView>
  );
}

The GestureHandlerRootView must wrap the drawer, because swipes are handled by the gesture library. Reanimated needs its Babel/Worklets setup, which the Expo template provides; always install these with expo install so the versions match your SDK. A drawer works in Expo Go only if the versions bundled in Expo Go match, otherwise use a development build.

Tabs or drawer?

Tabs versus drawer

Tabs 3 to 5 main areas, always visible
Drawer Many areas or rare actions
Combine Tabs inside, drawer for settings

Prefer tabs on phones for the most-used areas.

1 / 2

On a phone, tabs are easier to reach with a thumb and always show where you are. A drawer fits secondary areas (settings, help, account switching) or tablet and desktop layouts. You can nest: a drawer whose first screen is a (tabs) group.

Common mistakes

  • A header inside both the tab and its nested stack. Hide one.
  • Seven or more tabs. Use "More" patterns or a drawer instead.
  • Heavy work in tab screens that mount at app start: tabs are lazy by default, keep it that way unless needed.
  • Forgetting GestureHandlerRootView for the drawer, so swiping does nothing.
  • Using push to switch tabs. Use router.navigate('/explore') or a Link.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. How do you create a tab bar with Expo Router?

    A layout exporting a Tabs navigator makes the sibling route files into tabs.
  2. 2. How do you keep a route in the tab layout but hide it from the tab bar?

    href: null removes the tab button while keeping the route reachable.
  3. 3. A tab needs drill-down screens with their own header. What should you do?

    A nested Stack gives that tab its own history; hiding the tab's header avoids a double header.
  4. 4. What must wrap the Drawer layout?

    The drawer depends on gesture handling provided by GestureHandlerRootView.

Summary

  • A Tabs layout turns sibling files into tabs; groups like (tabs) keep URLs clean.
  • Customize icons, labels, badges and visibility with Tabs.Screen options.
  • Nest a Stack inside a tab for per-tab history; tabs keep their state when you switch.
  • Use a drawer for secondary areas and install its dependencies with expo install.

Next: Dynamic Routes and Params