File: stack.md | Updated: 11/15/2025
Hide navigation
Search
Ctrl K
Home Guides EAS Reference Learn
Archive Expo Snack Discord and Forums Newsletter
Copy page
Learn how to use the Stack navigator in Expo Router.
Copy page
A stack navigator is the foundational way of navigating between routes in an app. On Android, a stacked route animates on top of the current screen. On iOS, a stacked route animates from the right. Expo Router provides a Stack navigation component that creates a navigation stack and allows you to add new routes in your app.
This guide provides information on how you can create a Stack navigator in your project and customize an individual route's options and header.
You can use file-based routing to create a stack navigator. Here's an example file structure:
app
ā_layout.tsx
āindex.tsx
ādetails.tsx
This file structure produces a layout where the index route is the first route in the stack, and the details route is pushed on top of the index route when navigated.
You can use the app/_layout.tsx file to define your app's Stack navigator with these two routes:
app/_layout.tsx
Copy
import { Stack } from 'expo-router'; export default function Layout() { return <Stack />; }
Screen options and header configuration
You can use the <Stack.Screen name={routeName} /> component in the layout component route to statically configure a route's options. This is also useful for tabs
or drawers
as they need an icon defined ahead of time.
app/_layout.tsx
Copy
import { Stack } from 'expo-router'; export default function Layout() { return ( <Stack screenOptions={{ headerStyle: { backgroundColor: '#f4511e', }, headerTintColor: '#fff', headerTitleStyle: { fontWeight: 'bold', }, }}> {/* Optionally configure static options outside the route.*/} <Stack.Screen name="home" options={{}} /> </Stack> ); }
As an alternative to the <Stack.Screen> component, you can use navigation.setOptions()
to configure a route's options from within the route's component file.
app/index.tsx
Copy
import { Stack, useNavigation } from 'expo-router'; import { Text, View } from 'react-native'; import { useEffect } from 'react'; export default function Home() { const navigation = useNavigation(); useEffect(() => { navigation.setOptions({ headerShown: false }); }, [navigation]); return ( <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}> <Text>Home Screen</Text> </View> ); }
You can configure the header bar for all routes in a Stack navigator by using the screenOptions prop. This is useful for setting a common header style across all routes.
app/_layout.tsx
Copy
import { Stack } from 'expo-router'; export default function Layout() { return ( <Stack screenOptions={{ headerStyle: { backgroundColor: '#f4511e', }, headerTintColor: '#fff', headerTitleStyle: { fontWeight: 'bold', }, }} /> ); }
To configure the header bar dynamically for an individual route, use that navigator's <Stack.Screen> component in the routes's file. This is useful for interactions that change the UI.
app/index.tsx
Copy
import { Link, Stack } from 'expo-router'; import { Image, Text, View, StyleSheet } from 'react-native'; function LogoTitle() { return ( <Image style={styles.image} source={{ uri: 'https://reactnative.dev/img/tiny_logo.png' }} /> ); } export default function Home() { return ( <View style={styles.container}> <Stack.Screen options={{ title: 'My home', headerStyle: { backgroundColor: '#f4511e' }, headerTintColor: '#fff', headerTitleStyle: { fontWeight: 'bold', }, headerTitle: props => <LogoTitle {...props} />, }} /> <Text>Home Screen</Text> <Link href={{ pathname: 'details', params: { name: 'Bacon' } }}>Go to Details</Link> </View> ); } const styles = StyleSheet.create({ container: { flex: 1, alignItems: 'center', justifyContent: 'center', }, image: { width: 50, height: 50, }, });
Show More
The Stack navigator supports comprehensive header configuration options. Below are all the header-related options available:
| Option | Platform | Description |
| --- | --- | --- |
| header | Android<br><br>iOS | Custom header to use instead of the default header.<br><br>This accepts a function that returns a React Element to display as a header. The function receives an object containing the following properties as the argument:<br><br>* navigation - The navigation object for the current screen.<br>* route - The route object for the current screen.<br>* options - The options for the current screen<br>* back - Options for the back button, contains an object with a title property to use for back button label.<br><br>To set a custom header for all the screens in the navigator, you can specify this option in the screenOptions prop of the navigator.<br><br>Note that if you specify a custom header, the native functionality such as large title, search bar etc. won't work. |
| headerBackButtonDisplayMode | iOS | How the back button displays icon and title.<br><br>Supported values:<br><br>* "default" - Displays one of the following depending on the available space: previous screen's title, generic title (e.g. 'Back') or no title (only icon).<br>* "generic" ā Displays one of the following depending on the available space: generic title (e.g. 'Back') or no title (only icon).<br>* "minimal" ā Always displays only the icon without a title.<br><br>The space-aware behavior is disabled when:<br><br>* The iOS version is 13 or lower<br>* Custom font family or size is set (e.g. with headerBackTitleStyle)<br>* Back button menu is disabled (e.g. with headerBackButtonMenuEnabled)<br><br>In such cases, a static title and icon are always displayed. |
| headerBackButtonMenuEnabled | iOS | Boolean indicating whether to show the menu on longPress of iOS >= 14 back button. Defaults to true. |
| headerBackground | Android<br><br>iOS | Function which returns a React Element to render as the background of the header. This is useful for using backgrounds such as an image or a gradient. |
| headerBackImageSource | Android<br><br>iOS | Image to display in the header as the icon in the back button. Defaults to back icon image for the platform<br><br>* A chevron on iOS<br>* An arrow on Android |
| headerBackTitle | iOS | Title string used by the back button on iOS. Defaults to the previous scene's title, "Back" or arrow icon depending on the available space. See headerBackButtonDisplayMode to read about limitations and customize the behavior.<br><br>Use headerBackButtonDisplayMode: "minimal" to hide it. |
| headerBackTitleStyle | iOS | Style object for header back title. Supported properties:<br><br>* fontFamily<br>* fontSize |
| headerBackVisible | Android<br><br>iOS | Whether the back button is visible in the header. You can use it to show a back button alongside headerLeft if you have specified it.<br><br>This will have no effect on the first screen in the stack. |
| headerBlurEffect | iOS | Blur effect for the translucent header. The headerTransparent option needs to be set to true for this to work.<br><br>Supported values: extraLight, light, dark, regular, prominent, systemUltraThinMaterial, systemThinMaterial, systemMaterial, systemThickMaterial, systemChromeMaterial, systemUltraThinMaterialLight, systemThinMaterialLight, systemMaterialLight, systemThickMaterialLight, systemChromeMaterialLight, systemUltraThinMaterialDark, systemThinMaterialDark, systemMaterialDark, systemThickMaterialDark, systemChromeMaterialDark |
| headerLargeStyle | iOS | Style of the header when a large title is shown. The large title is shown if headerLargeTitle is true and the edge of any scrollable content reaches the matching edge of the header.<br><br>Supported properties:<br><br>* backgroundColor |
| headerLargeTitle | iOS | Whether to enable header with large title which collapses to regular header on scroll. Defaults to false.<br><br>For large title to collapse on scroll, the content of the screen should be wrapped in a scrollable view such as ScrollView or FlatList. If the scrollable area doesn't fill the screen, the large title won't collapse on scroll. You also need to specify contentInsetAdjustmentBehavior="automatic" in your ScrollView, FlatList etc. |
| headerLargeTitleShadowVisible | Android<br><br>iOS | Whether drop shadow of header is visible when a large title is shown. |
| headerLargeTitleStyle | iOS | Style object for large title in header. Supported properties:<br><br>* fontFamily<br>* fontSize<br>* fontWeight<br>* color |
| headerLeft | Android<br><br>iOS | Function which returns a React Element to display on the left side of the header. This replaces the back button. See headerBackVisible to show the back button along side left element. It receives the following properties in the arguments:<br><br>* tintColor - The tint color to apply. Defaults to the theme's primary color.<br>* canGoBack - Boolean indicating whether there is a screen to go back to.<br>* label - Label text for the button. Usually the title of the previous screen.<br>* href - The href to use for the anchor tag on web |
| headerRight | Android<br><br>iOS | Function which returns a React Element to display on the right side of the header. It receives the following properties in the arguments:<br><br>* tintColor - The tint color to apply. Defaults to the theme's primary color.<br>* canGoBack - Boolean indicating whether there is a screen to go back to. |
| headerSearchBarOptions | iOS | Options to render a native search bar on iOS. Search bars are rarely static so normally it is controlled by passing an object to headerSearchBarOptions navigation option in the component's body.<br><br>You also need to specify contentInsetAdjustmentBehavior="automatic" in your ScrollView, FlatList etc. If you don't have a ScrollView, specify headerTransparent: false.<br><br>Supported properties are:<br><br>ref<br><br>Ref to manipulate the search input imperatively. It contains the following methods:<br><br>* focus - focuses the search bar<br>* blur - removes focus from the search bar<br>* setText - sets the search bar's content to given value<br>* clearText - removes any text present in the search bar input field<br>* cancelSearch - cancel the search and close the search bar<br><br>autoCapitalize<br><br>Controls whether the text is automatically auto-capitalized as it is entered by the user. Possible values:<br><br>* none<br>* words<br>* sentences<br>* characters<br><br>Defaults to sentences.<br><br>autoFocus<br><br>Whether to automatically focus search bar when it's shown. Defaults to false.<br><br>barTintColor<br><br>The search field background color. By default bar tint color is translucent.<br><br>tintColor<br><br>The color for the cursor caret and cancel button text.<br><br>cancelButtonText<br><br>The text to be used instead of default Cancel button text.<br><br>disableBackButtonOverride<br><br>Whether the back button should close search bar's text input or not. Defaults to false.<br><br>hideNavigationBar<br><br>Boolean indicating whether to hide the navigation bar during searching. Defaults to true.<br><br>hideWhenScrolling<br><br>Boolean indicating whether to hide the search bar when scrolling. Defaults to true.<br><br>inputType<br><br>The type of the input. Defaults to "text".<br><br>Supported values: "text", "phone", "number", "email"<br><br>obscureBackground<br><br>Boolean indicating whether to obscure the underlying content with semi-transparent overlay. Defaults to true.<br><br>placeholder<br><br>Text displayed when search field is empty.<br><br>textColor<br><br>The color of the text in the search field.<br><br>hintTextColor<br><br>The color of the hint text in the search field.<br><br>headerIconColor<br><br>The color of the search and close icons shown in the header<br><br>shouldShowHintSearchIcon<br><br>Whether to show the search hint icon when search bar is focused. Defaults to true.<br><br>onBlur<br><br>A callback that gets called when search bar has lost focus.<br><br>onCancelButtonPress<br><br>A callback that gets called when the cancel button is pressed.<br><br>onChangeText<br><br>A callback that gets called when the text changes. It receives the current text value of the search bar. |
| headerShadowVisible | Android<br><br>iOS | Whether to hide the elevation shadow (Android) or the bottom border (iOS) on the header. |
| headerShown | Android<br><br>iOS | Whether to show the header. The header is shown by default. Setting this to false hides the header. |
| headerStyle | Android<br><br>iOS | Style object for header. Supported properties:<br><br>* backgroundColor |
| headerTintColor | Android<br><br>iOS | Tint color for the header. Changes the color of back button and title. |
| headerTitle | Android<br><br>iOS | String or a function that returns a React Element to be used by the header. Defaults to title or name of the screen.<br><br>When a function is passed, it receives tintColor andchildren in the options object as an argument. The title string is passed in children.<br><br>Note that if you render a custom element by passing a function, animations for the title won't work. |
| headerTitleAlign | Android<br><br>iOS | How to align the header title. Possible values:<br><br>* left<br> <br>* center<br> <br><br>Defaults to left on platforms other than iOS.<br><br>Not supported on iOS. It's always center on iOS and cannot be changed. |
| headerTitleStyle | Android<br><br>iOS | Style object for header title. Supported properties:<br><br>* fontFamily<br>* fontSize<br>* fontWeight<br>* color |
| headerTransparent | Android<br><br>iOS | Boolean indicating whether the navigation bar is translucent.<br><br>Defaults to false. Setting this to true makes the header absolutely positioned - so that the header floats over the screen so that it overlaps the content underneath, and changes the background color to transparent unless specified in headerStyle.<br><br>This is useful if you want to render a semi-transparent header or a blurred background.<br><br>Note that if you don't want your content to appear under the header, you need to manually add a top margin to your content. React Navigation won't do it automatically.<br><br>To get the height of the header, you can use HeaderHeightContext with React's Context API or useHeaderHeight. |
| title | Android<br><br>iOS | String that can be used as a fallback for headerTitle. |
| unstable_headerLeftItems | iOS | This option is experimental and may change in a minor release.<br><br>Function which returns an array of items to display as on the left side of the header. This will override headerLeft if both are specified. It receives the following properties in the arguments:<br><br>* tintColor - The tint color to apply. Defaults to the theme's primary color.<br>* canGoBack - Boolean indicating whether there is a screen to go back to.<br><br>See Header items for more information. |
| unstable_headerRightItems | iOS | This option is experimental and may change in a minor release.<br><br>Function which returns an array of items to display as on the right side of the header. This will override headerRight if both are specified. It receives the following properties in the arguments:<br><br>* tintColor - The tint color to apply. Defaults to the theme's primary color.<br>* canGoBack - Boolean indicating whether there is a screen to go back to.<br><br>See Header items for more information. |
For additional details and navigator-specific examples, see React Navigation's Native Stack Navigator documentation .
To configure a route's option dynamically, you can always use the <Stack.Screen> component in that route's file.
As an alternative, you can also use the imperative API's router.setParams()
function to configure the route dynamically.
app/details.tsx
Copy
import { Stack, useLocalSearchParams, useRouter } from 'expo-router'; import { View, Text, StyleSheet } from 'react-native'; export default function Details() { const router = useRouter(); const params = useLocalSearchParams(); return ( <View style={styles.container}> <Stack.Screen options={{ title: params.name, }} /> <Text onPress={() => { router.setParams({ name: 'Updated' }); }}> Update the title </Text> </View> ); } const styles = StyleSheet.create({ container: { flex: 1, alignItems: 'center', justifyContent: 'center', }, });
Show More
You can add buttons to the header by using the headerLeft and headerRight options. These options accept a React component that renders in the header.
app/index.tsx
Copy
import { Stack } from 'expo-router'; import { Button, Text, Image, StyleSheet } from 'react-native'; import { useState } from 'react'; function LogoTitle() { return ( <Image style={styles.image} source={{ uri: 'https://reactnative.dev/img/tiny_logo.png' }} /> ); } export default function Home() { const [count, setCount] = useState(0); return ( <> <Stack.Screen options={{ headerTitle: props => <LogoTitle {...props} />, headerRight: () => <Button onPress={() => setCount(c => c + 1)} title="Update count" />, }} /> <Text>Count: {count}</Text> </> ); } const styles = StyleSheet.create({ image: { width: 50, height: 50, }, });
Show More
For a complete list of all available other screen options including animations, gestures, and other configurations:
| Option | Platform | Description |
| --- | --- | --- |
| animation | Android | How the screen should animate when pushed or popped.<br><br>Supported values: default, fade, fade_from_bottom, flip, simple_push, slide_from_bottom, slide_from_right, slide_from_left, none |
| animationDuration | iOS | Changes the duration (in milliseconds) of slide_from_bottom, fade_from_bottom, fade and simple_push transitions on iOS. Defaults to 350.<br><br>The duration of default and flip transitions isn't customizable. |
| animationMatchesGesture | iOS | Whether the gesture to dismiss should use animation provided to animation prop. Defaults to false.<br><br>Doesn't affect the behavior of screens presented modally. |
| animationTypeForReplace | Android<br><br>iOS | The type of animation to use when this screen replaces another screen. Defaults to push.<br><br>Supported values: push, pop |
| autoHideHomeIndicator | iOS | Boolean indicating whether the home indicator should prefer to stay hidden. Defaults to false. |
| contentStyle | Android<br><br>iOS | Style object for the scene content. |
| freezeOnBlur | iOS | Boolean indicating whether to prevent inactive screens from re-rendering. Defaults to false. Defaults to true when enableFreeze() from react-native-screens package is run at the top of the application.<br><br>Only supported on iOS and Android. |
| fullScreenGestureEnabled | iOS | Whether the gesture to dismiss should work on the whole screen. Using gesture to dismiss with this option results in the same transition animation as simple_push. This behavior can be changed by setting customAnimationOnGesture prop. Achieving the default iOS animation isn't possible due to platform limitations. Defaults to false.<br><br>Doesn't affect the behavior of screens presented modally. |
| fullScreenGestureShadowEnabled | Android<br><br>iOS | Whether the full screen dismiss gesture has shadow under view during transition. Defaults to true.<br><br>This does not affect the behavior of transitions that don't use gestures enabled by fullScreenGestureEnabled prop. |
| gestureDirection | iOS | Sets the direction in which you should swipe to dismiss the screen.<br><br>Supported values: vertical, horizontal<br><br>When using vertical option, options fullScreenGestureEnabled: true, customAnimationOnGesture: true and animation: 'slide_from_bottom' are set by default. |
| gestureEnabled | iOS | Whether you can use gestures to dismiss this screen. Defaults to true. |
| navigationBarColor | Android | This option is deprecated and will be removed in a future release (for apps targeting Android SDK 35 or above edge-to-edge mode is enabled by default and it is expected that the edge-to-edge will be enforced in future SDKs, see here for more information).<br><br>Sets the navigation bar color. Defaults to initial status bar color. |
| navigationBarHidden | Android | Boolean indicating whether the navigation bar should be hidden. Defaults to false. |
| orientation | Android | The display orientation to use for the screen.<br><br>Supported values: default, all, portrait, portrait_up, portrait_down, landscape, landscape_left, landscape_right |
| presentation | Android | How should the screen be presented.<br><br>Supported values: card, modal, transparentModal, containedModal, containedTransparentModal, fullScreenModal, formSheet |
| sheetAllowedDetents | Android | Works only when presentation is set to formSheet.<br><br>Describes heights where a sheet can rest.<br><br>Supported values: fitToContents<br><br>Defaults to [1.0]. |
| sheetCornerRadius | Android | Works only when presentation is set to formSheet.<br><br>The corner radius that the sheet will try to render with.<br><br>If set to non-negative value it will try to render sheet with provided radius, else it will apply system default.<br><br>If left unset, system default is used. |
| sheetElevation | Android | Works only when presentation is set to formSheet.<br><br>Integer value describing elevation of the sheet, impacting shadow on the top edge of the sheet.<br><br>Not dynamic - changing it after the component is rendered won't have an effect.<br><br>Defaults to 24. |
| sheetExpandsWhenScrolledToEdge | iOS | Works only when presentation is set to formSheet.<br><br>Whether the sheet should expand to larger detent when scrolling.<br><br>Defaults to true.<br><br>Please note that for this interaction to work, the ScrollView must be "first-subview-chain" descendant of the Screen component. This restriction is due to platform requirements. |
| sheetGrabberVisible | iOS | Works only when presentation is set to formSheet.<br><br>Boolean indicating whether the sheet shows a grabber at the top.<br><br>Defaults to false. |
| sheetInitialDetentIndex | Android | Works only when presentation is set to formSheet.<br><br>Index of the detent the sheet should expand to after being opened.<br><br>If the specified index is out of bounds of sheetAllowedDetents array, in dev environment more errors will be thrown, in production the value will be reset to default value.<br><br>Additionaly there is last value available, when set the sheet will expand initially to last (largest) detent.<br><br>Defaults to 0 - which represents first detent in the detents array. |
| sheetLargestUndimmedDetentIndex | Android | Works only when presentation is set to formSheet.<br><br>The largest sheet detent for which a view underneath won't be dimmed.<br><br>This prop can be set to an number, which indicates index of detent in sheetAllowedDetents array for which there won't be a dimming view beneath the sheet.<br><br>Additionaly there are following options available:<br><br>* none - there will be dimming view for all detents levels,<br>* last - there won't be a dimming view for any detent level.<br><br>Defaults to none, indicating that the dimming view should be always present. |
| statusBarAnimation | Android | Sets the status bar animation (similar to the StatusBar component). Defaults to fade on iOS and none on Android.<br><br>Supported values: "fade", "none", "slide"<br><br>On Android, setting either fade or slide will set the transition of status bar color. On iOS, this option applies to appereance animation of the status bar.<br><br>Requires setting View controller-based status bar appearance -> YES (or removing the config) in your Info.plist file. |
| statusBarBackgroundColor | Android | This option is deprecated and will be removed in a future release (for apps targeting Android SDK 35 or above edge-to-edge mode is enabled by default and it is expected that the edge-to-edge will be enforced in future SDKs, see here for more information).<br><br>Sets the background color of the status bar (similar to the StatusBar component). |
| statusBarHidden | Android | Whether the status bar should be hidden on this screen.<br><br>Requires setting View controller-based status bar appearance -> YES (or removing the config) in your Info.plist file. |
| statusBarStyle | Android | Sets the status bar color (similar to the StatusBar component).<br><br>Supported values: "auto", "inverted", "dark", "light"<br><br>Defaults to auto on iOS and light on Android.<br><br>Requires setting View controller-based status bar appearance -> YES (or removing the config) in your Info.plist file. |
| statusBarTranslucent | Android | This option is deprecated and will be removed in a future release (for apps targeting Android SDK 35 or above edge-to-edge mode is enabled by default and it is expected that the edge-to-edge will be enforced in future SDKs, see here for more information).<br><br>Sets the translucency of the status bar (similar to the StatusBar component). Defaults to false. |
| tabBarAccessibilityLabel | Android<br><br>iOS | Accessibility label for the tab button. This is read by the screen reader when the user taps the tab. It's recommended to set this if you don't have a label for the tab. |
| tabBarActiveBackgroundColor | Android<br><br>iOS | Background color for the active tab. |
| tabBarActiveTintColor | Android<br><br>iOS | Color for the icon and label in the active tab. |
| tabBarBackground | Android<br><br>iOS | Function which returns a React Element to use as background for the tab bar. You could render an image, a gradient, blur view etc.:<br><br>import { BlurView } from 'expo-blur'; // ... <Tab.Navigator screenOptions={{ tabBarStyle: { position: 'absolute' }, tabBarBackground: () => ( <BlurView tint="light" intensity={100} style={StyleSheet.absoluteFill} /> ), }} ><br><br>When using BlurView, make sure to set position: 'absolute' in tabBarStyle as well. You'd also need to use useBottomTabBarHeight to add bottom padding to your content. |
| tabBarBadge | Android<br><br>iOS | Text to show in a badge on the tab icon. Accepts a string or a number. |
| tabBarBadgeStyle | Android<br><br>iOS | Style for the badge on the tab icon. You can specify a background color or text color here. |
| tabBarButton | Android<br><br>iOS | Function which returns a React element to render as the tab bar button. It wraps the icon and label. Renders Pressable by default.<br><br>You can specify a custom implementation here:<br><br>tabBarButton: (props) => <TouchableOpacity {...props} />; |
| tabBarButtonTestID | Android<br><br>iOS | ID to locate this tab button in tests. |
| tabBarHideOnKeyboard | Android<br><br>iOS | Whether the tab bar is hidden when the keyboard opens. Defaults to false. |
| tabBarIcon | Android<br><br>iOS | Function that given { focused: boolean, color: string, size: number } returns a React.Node, to display in the tab bar. |
| tabBarIconStyle | Android<br><br>iOS | Style object for the tab icon. |
| tabBarInactiveBackgroundColor | Android<br><br>iOS | Background color for the inactive tabs. |
| tabBarInactiveTintColor | Android<br><br>iOS | Color for the icon and label in the inactive tabs. |
| tabBarItemStyle | Android<br><br>iOS | Style object for the tab item container. |
| tabBarLabel | Android<br><br>iOS | Title string of a tab displayed in the tab bar or a function that given { focused: boolean, color: string } returns a React.Node, to display in tab bar. When undefined, scene title is used. To hide, see tabBarShowLabel. |
| tabBarLabelPosition | Android<br><br>iOS | Whether the label is shown below the icon or beside the icon.<br><br>By default, the position is chosen automatically based on device width.<br><br>* below-icon: the label is shown below the icon (typical for iPhones)<br> <br>* beside-icon the label is shown next to the icon (typical for iPad) |
| tabBarLabelStyle | Android<br><br>iOS | Style object for the tab label. |
| tabBarPosition | Android<br><br>iOS | Position of the tab bar. Available values are:<br><br>* bottom (Default)<br>* top<br>* left<br>* right<br><br>When the tab bar is positioned on the left or right, it is styled as a sidebar. This can be useful when you want to show a sidebar on larger screens and a bottom tab bar on smaller screens:<br><br><Tab.Navigator screenOptions={{ tabBarPosition: dimensions.width < 600 ? 'bottom' : 'left', tabBarLabelPosition: 'below-icon', }} > |
| tabBarShowLabel | Android<br><br>iOS | Whether the tab label should be visible. Defaults to true. |
| tabBarStyle | Android<br><br>iOS | Style object for the tab bar. You can configure styles such as background color here.<br><br>To show your screen under the tab bar, you can set the position style to absolute:<br><br><Tab.Navigator screenOptions={{ tabBarStyle: { position: 'absolute' }, }} ><br><br>You also might need to add a bottom margin to your content if you have an absolutely positioned tab bar. React Navigation won't do it automatically. See useBottomTabBarHeight for more details. |
| tabBarVariant | Android<br><br>iOS | Variant of the tab bar. Available values are:<br><br>* uikit (Default) - The tab bar will be styled according to the iOS UIKit guidelines.<br>* material - The tab bar will be styled according to the Material Design guidelines.<br><br>The material variant is currently only supported when the tabBarPosition is set to left or right. |
For additional details and navigator-specific examples, see React Navigation's Native Stack Navigator documentation .
By default, the Stack navigator removes duplicate screens when pushing a route that is already in the stack. For example, if you push the same screen twice, the second push will be ignored. You can change this push behavior by providing a custom getId() function to the <Stack.Screen>.
For example, the index route in the following layout structure shows a list of different user profiles in the app. Let's make the [details] route a dynamic route
so that the app user can navigate to see a profile's details.
app
ā_layout.tsx
āindex.tsx
ā[details].tsx``matches dynamic paths like '/details1'
The Stack navigator will push a new screen every time the app user navigates to a different profile but will fail. If you provide a getId() function that returns a new ID every time, the Stack will push a new screen every time the app user navigates to a profile.
You can use the <Stack.Screen name="[profile]" getId={}> component in the layout component route to modify the push behavior:
app/_layout.tsx
Copy
import { Stack } from 'expo-router'; export default function Layout() { return ( <Stack> <Stack.Screen name="[profile]" getId={ ({ params }) => String(Date.now()) } /> </Stack> ); }
There are different actions you can use to dismiss and remove one or many routes from a stack.
dismiss actionDismisses the last screen in the closest stack. If the current screen is the only route in the stack, it will dismiss the entire stack.
You can optionally pass a positive number to dismiss up to that specified number of screens.
Dismiss is different from back as it targets the closest stack and not the current navigator. If you have nested navigators, calling dismiss will take you back multiple screens.
app/settings.tsx
Copy
import { Button, View } from 'react-native'; import { useRouter } from 'expo-router'; export default function Settings() { const router = useRouter(); const handleDismiss = (count: number) => { router.dismiss(count) }; return ( <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}> <Button title="Go to first screen" onPress={() => handleDismiss(3)} /> </View> ); }
dismissTo action
dismissTowas added in Expo Router4.0.8. It operates similarly to thenavigationfunction in Expo Router v3.
Dismisses screens in the current <Stack /> until the specified Href is reached. If the Href is absent in the history, a push action will be performed instead.
For example, consider the history of /one, /two, /three routes, where /three is the current route. The action router.dismissTo('/one') will cause the history to go back twice, while router.dismissTo('/four') will push the history forward to the /four route.
app/settings.tsx
Copy
import { Button, View, Text } from 'react-native'; import { useRouter } from 'expo-router'; export default function Settings() { const router = useRouter(); const handleDismissAll = () => { router.dismissTo('/') }; return ( <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}> <Button title="Go to first screen" onPress={handleDismissAll} /> </View> ); }
dismissAll actionTo return to the first screen in the closest stack. This is similar to popToTop
stack action.
For example, the home route is the first screen, and the settings is the last. To go from settings to home route you'll have to go back to details. However, using the dismissAll action, you can go from settings to home and dismiss any screen in between.
app/settings.tsx
Copy
import { Button, View, Text } from 'react-native'; import { useRouter } from 'expo-router'; export default function Settings() { const router = useRouter(); const handleDismissAll = () => { router.dismissAll() }; return ( <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}> <Button title="Go to first screen" onPress={handleDismissAll} /> </View> ); }
canDismiss actionTo check if it is possible to dismiss the current screen. Returns true if the router is within a stack with more than one screen in the stack's history.
app/settings.tsx
Copy
import { Button, View } from 'react-native'; import { useRouter } from 'expo-router'; export default function Settings() { const router = useRouter(); const handleDismiss = (count: number) => { if (router.canDismiss()) { router.dismiss(count) } }; return ( <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}> <Button title="Maybe dismiss" onPress={() => handleDismiss()} /> </View> ); }
Relation with Native Stack Navigator
The Stack navigator in Expo Router wraps the Native Stack Navigator
from React Navigation. Options available in the Native Stack Navigator are all available in the Stack navigator in Expo Router.
You can also use the JavaScript-powered @react-navigation/stack library to create a custom layout component by wrapping this library with the withLayoutContext.
In the following example, JsStack component is defined using @react-navigation/stack library:
layouts/js-stack.tsx
Copy
import { ParamListBase, StackNavigationState } from '@react-navigation/native'; import { createStackNavigator, StackNavigationEventMap, StackNavigationOptions, } from '@react-navigation/stack'; import { withLayoutContext } from 'expo-router'; const { Navigator } = createStackNavigator(); export const JsStack = withLayoutContext< StackNavigationOptions, typeof Navigator, StackNavigationState<ParamListBase>, StackNavigationEventMap >(Navigator);
After defining the JsStack component, you can use it in your app:
app/_layout.tsx
Copy
import { JsStack } from '../layouts/js-stack'; export default function Layout() { return ( <JsStack screenOptions={ { %%placeholder-start%%... %%placeholder-end%% } } /> ); }
For more information on available options, see @react-navigation/stack documentation
.
Starting from iOS 26, navigation headers adopt the system's "Liquid Glass" effect by default. It cannot be disabled per screen, so you need to opt out using a global configuration.
UIDesignRequiresCompatibilityNote: Not supported in Expo Go.This method is a temporary workaround. From iOS 27, this option will be removed by Apple and you cannot opt out of the Liquid Glass effect.
Create a development build
and set the UIDesignRequiresCompatibility
property to true in app config
:
app.json
Copy
{ "ios": { "infoPlist": { "UIDesignRequiresCompatibility": true } } }
Switch from native navigation library (@react-navigation/native
) to a JavaScript-based stack navigator library such as @react-navigation/stack
, which gives you full control over the header UI but at the cost of performance benefits of using the highly optimized iOS navigation views/controllers.
For more information, see JavaScript stack with @react-navigation/stack
.