0Pricing
React Native Academy · レッスン

ボトムタブナビゲーター

3つのタブを持つボトムタブナビゲーターを作成し、ベクターアイコンライブラリで各タブのアイコンをカスタマイズして、アクティブ時のティントカラーを設定します

「ボトムタブナビゲーター」はCoddyKit上の無料React Native Academyレッスンです。 これはレッスン3/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはReact Native Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 React Native Academyコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

What is a Bottom Tab Navigator?

A bottom tab navigator renders a tab bar at the bottom of the screen with one tab per registered screen. Tapping a tab switches to that screen. This pattern is very common in mobile apps (Instagram, Twitter, Airbnb) and is provided by the @react-navigation/bottom-tabs package.

Installing the Bottom Tabs Package

Install the bottom tabs navigator package separately from the React Navigation core. If you are using Expo, also make sure react-native-screens and react-native-safe-area-context are already installed from the previous setup step.

npm install @react-navigation/bottom-tabs

Creating the Tab Navigator

Call createBottomTabNavigator() to get a Tab object with Tab.Navigator and Tab.Screen components. Register screens exactly as you would in a stack navigator. Each Tab.Screen name becomes the default tab label.

import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';

const Tab = createBottomTabNavigator();

function MyTabs() {
  return (
    <Tab.Navigator>
      <Tab.Screen name='Home' component={HomeScreen} />
      <Tab.Screen name='Search' component={SearchScreen} />
      <Tab.Screen name='Profile' component={ProfileScreen} />
    </Tab.Navigator>
  );
}

Adding Icons to Tab Screens

Each tab should have an icon to help users recognize it quickly. Use tabBarIcon inside the screen's options prop. The render function receives a focused boolean and a color so you can render different icons or colors for active vs inactive tabs.

import { Ionicons } from '@expo/vector-icons';

<Tab.Screen
  name='Home'
  component={HomeScreen}
  options={{
    tabBarIcon: ({ focused, color, size }) => (
      <Ionicons
        name={focused ? 'home' : 'home-outline'}
        size={size}
        color={color}
      />
    ),
  }}
/>

Customizing Active and Inactive Colors

Set tabBarActiveTintColor and tabBarInactiveTintColor in screenOptions to control the color of tab icons and labels for the selected and unselected states. These color values are passed into the tabBarIcon render function automatically.

<Tab.Navigator
  screenOptions={{
    tabBarActiveTintColor: '#6200ee',
    tabBarInactiveTintColor: '#888',
  }}
>

Hiding the Tab Bar on Specific Screens

Sometimes you want to hide the tab bar when navigating to a detail screen. Set tabBarStyle: { display: 'none' } in the screen's options or use the navigation prop to toggle it dynamically with navigation.setOptions.

<Tab.Screen
  name='Details'
  component={DetailsScreen}
  options={{ tabBarStyle: { display: 'none' } }}
/>

Changing Tab Label and Badge

Override the tab label with tabBarLabel in the screen options. Add a notification badge using tabBarBadge to show a count indicator on the icon — useful for messaging or notification tabs. Set tabBarBadge to a number or string.

<Tab.Screen
  name='Messages'
  component={MessagesScreen}
  options={{
    tabBarLabel: 'Inbox',
    tabBarBadge: 3,
  }}
/>

Styling the Tab Bar Background

Customize the tab bar background color and border using tabBarStyle in screenOptions. You can set backgroundColor, borderTopColor, elevation (Android shadow), and height to match your design system.

<Tab.Navigator
  screenOptions={{
    tabBarStyle: {
      backgroundColor: '#1a1a2e',
      borderTopColor: '#333',
      height: 60,
    },
    tabBarLabelStyle: { fontSize: 12, paddingBottom: 4 },
  }}
>

Navigating Between Tabs Programmatically

Use navigation.navigate('TabName') to switch to a specific tab from any screen within the navigator. This is useful when a button action in one tab should take the user to another section of the app. The active tab's state is preserved.

function HomeScreen({ navigation }) {
  return (
    <Button
      title='Go to Profile'
      onPress={() => navigation.navigate('Profile')}
    />
  );
}

Listening to Tab Press Events

Use the tabPress event on navigation to intercept a tab press. This is useful for scrolling a list back to the top when the user taps the active tab. Call e.preventDefault() if you want to handle the press yourself without the default navigation action.

navigation.addListener('tabPress', (e) => {
  // Prevent default behavior
  e.preventDefault();
  // Custom action: scroll to top, show modal, etc.
});

Nesting a Stack Inside a Tab

In real apps each tab often contains its own stack of screens. Simply nest a Stack.Navigator as the component for a Tab.Screen. The stack renders inside the tab area while the tab bar remains visible at the bottom of the screen.

function HomeStack() {
  return (
    <Stack.Navigator>
      <Stack.Screen name='Home' component={HomeScreen} />
      <Stack.Screen name='Post' component={PostScreen} />
    </Stack.Navigator>
  );
}

<Tab.Screen name='HomeTab' component={HomeStack} />

Quick Check

Test your understanding of Bottom Tab Navigator concepts from this lesson.

Lesson Recap

In this lesson you learned: install and create a bottom tab navigator with createBottomTabNavigator, add icons using tabBarIcon in screen options, and customize colors, labels, and badges globally via screenOptions. Next up we explore the Drawer Navigator and nested navigators.

よくある質問

「ボトムタブナビゲーター」レッスンは無料ですか?

はい。「ボトムタブナビゲーター」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、React Native Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 React Native Academyコースには全4レッスンが含まれています。

「ボトムタブナビゲーター」で何を学びますか?

3つのタブを持つボトムタブナビゲーターを作成し、ベクターアイコンライブラリで各タブのアイコンをカスタマイズして、アクティブ時のティントカラーを設定します ブラウザで直接実行するハンズオンコードでReact Native Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

React Native Academyを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのReact Native Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン3/4です。

「ボトムタブナビゲーター」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このReact Native Academyレッスンでコードを書いて実行できますか?

はい。すべてのReact Native Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. React Navigationのインストールと設定
  2. 画面間の移動とParamsの受け渡し
  3. ボトムタブナビゲーター
  4. ドロワーナビゲーターとネストしたナビゲーター
← React Native Academyに戻る