Stack Navigation styling in React Native allows you to customize headers, transitions, colors, titles, and gestures for screens managed by createNativeStackNavigator or createStackNavigator.
screenOptionsoptionsStack navigator styling is controlled using configuration objects. You can apply styles globally or override them for individual screens.
// Import stack navigator from React Navigation
import { createNativeStackNavigator } from "@react-navigation/native-stack";
const Stack = createNativeStackNavigator();
function AppStack() {
return (
<Stack.Navigator
screenOptions={{
headerStyle: { backgroundColor: "#2563eb" },
headerTintColor: "#ffffff",
headerTitleStyle: { fontWeight: "bold" }
}}
>
<Stack.Screen name="Home" component={HomeScreen} />
</Stack.Navigator>
);
}
The header background becomes blue, text turns white, and the title appears bold across all stack screens.
Use the simulator below to experiment with header styling properties. Change the controls to see how the code and the mobile preview update in real-time.
// Dynamic header color using props
options={{
headerStyle: {
backgroundColor: route.params?.color || "#16a34a"
}
}}
screenOptions for consistency