Top Tab Navigation in React Native allows users to switch between screens using tabs displayed at the top. It is commonly used for categorizing related content in a clean and intuitive way.
Top Tab Navigation is implemented using a material top tab navigator. Each tab represents a separate screen component.
// Import top tab navigator from react-navigation
import { createMaterialTopTabNavigator } from '@react-navigation/material-top-tabs';
// Create a top tab navigator with two screens
const Tab = createMaterialTopTabNavigator();
function MyTabs() {
return (
<Tab.Navigator>
<Tab.Screen name="Home" component={HomeScreen} />
<Tab.Screen name="Profile" component={ProfileScreen} />
</Tab.Navigator>
);
}
This setup displays two tabs at the top. Users can tap or swipe to switch between Home and Profile screens.
Click the tabs below to see how the Top Tab Navigator transitions between screens. Note the sliding indicator animation.
Welcome to your feed!
Find new content here.
Settings & Personal Info.