The problem of Safe Areas
Recently I've been working on improving how React Navigation handles safe areas across different devices and platforms.
In this post, I'll share various challenges I faced and the approach I plan to take to address them.
A bit of history
When I started working with React Native back in 2015, the only thing we needed to handle was the status bar on iOS. But it changed over the years:
- 2015: The status bar was 20pt tall on all iPhones (40pt during a phone call, but let's not talk about that). It was opaque on Android, so there was nothing to handle.
- 2016: We got a
StatusBarcomponent with atranslucentprop in React Native 0.20 (Android 5 Lollipop and later), thenStatusBar.currentHeightin React Native 0.23 to add padding for the status bar. - 2017: Apple released the iPhone X. The status bar height now depended on the model (20pt on older iPhones and 44pt on the iPhone X), and we also had to handle the home indicator and the notch in landscape.
- 2017: We got
contentInsetAdjustmentBehavioronScrollViewin React Native 0.48, and a built-inSafeAreaViewin React Native 0.50. ButSafeAreaViewonly worked on iOS 11 and later, so we still needed to handle older iPhones and Android separately. - 2018: Android devices started getting notches, hole-punch cameras, and other display cutouts.
Since React Navigation renders UI such as headers and tab bars which may overlap with the status bar, the notch, home indicator etc., we needed to handle this. Initially, we used react-native-iphone-x-helper for this. It detected the iPhone X from the screen dimensions, which worked at the time, but wasn't future proof.
We needed a better solution. The obvious choice was to use the built-in SafeAreaView component on supported iOS versions, but it had a big problem. Back then, React Navigation was purely JS-based, using transform for animations. The SafeAreaView didn't work well with it, as the safe area insets depended on the transforms as well, so as a screen animated, the insets would change and it would cause jumps or stale layout.
The current state
The react-native-safe-area-context library came out in August 2019. It solved all our problems:
- It worked on both Android & iOS, so we had a unified API
- The insets were relative to
SafeAreaProvider, so we could render one at the root to avoid jumps or stale layout - It had a hook-based API with
useSafeAreaInsets, which gave us actual inset values for calculations
We started using it in React Navigation 5. It wasn't perfect, but it was close.
Why it's not enough
In 2025, Apple added windowed mode to iPadOS. In windowed mode, apps have window controls (traffic light buttons) like on macOS, and can be freely resized. This added a new problem. Safe areas don't automatically avoid the traffic light buttons. There is a new cornerAdaptation option that accounts for rounded corners and window controls.
When working on React Navigation 8, I wanted to solve it. We mainly had 2 scenarios where the window controls covered our content:
- The left side of headers
- Scrollable content in left drawers
After some experimentation, I landed on an UNSTABLE_CornerInset component with help from Michał Osadnik. It had to account for 2 things:
- It needed to be dynamic, e.g. on a larger window size, the user could render a sidebar/permanent drawer, so the header shouldn't apply the insets. But it should apply the insets when this sidebar gets hidden.
- It needed to stay static during animations, e.g. when pushing a new stack screen, we don't want the header insets to start from 0 and then jump to the actual inset as the header intersects with the window controls.
Initially, we had the same problem as React Native's SafeAreaView, where the insets would change during animations and cause jumps or stale layout. After many iterations, the solution I arrived at was to:
- Render a hidden view at the same bounds, but attached to the window, instead of getting the insets of the view itself.
- Use the insets reported by UIKit for the hidden view, so they don't change during animations.
- Listen to
transitionEndevents of screens and window resize to re-calculate and re-apply the insets.
It wasn't an ideal implementation, but it kind of worked.
Then, Apple announced the iPhone Duo in September 2026. The status bar was now on the right side of the screen, and UI controls could be placed in the status bar region. I wanted to figure out how to support placing items in the status bar area of iPhone Duo without being overlapped by the status bar. This led me to 2 APIs:
The reserved regions API was too low-level, which left UIView.LayoutRegion, specifically UIView.LayoutRegion.bar. So I worked on adding a component for that, but after some thinking, it made more sense to add everything supported by UIView.LayoutRegion: bar, margins, safeArea, readableContent instead of only bar.
Now, there was overlap between UNSTABLE_CornerInset and safeArea, because UNSTABLE_CornerInset was essentially safe area with cornerAdaptation. So it was time to rethink the APIs we expose.
I hadn't started experimenting with Android yet. But after talking to Kacper Kafara, I learned that we had a similar situation on Android with multiple types of insets with the WindowInsets API.
Our approach
So far, SafeAreaView has been the main way safe area insets have been used in React Native. But as we get more and more form factors and layouts, I'm not sure it's the ideal API anymore, at least not if we want to have the same flexibility as the underlying platform APIs.
It made more sense to have platform-specific components that expose all the different types of insets and regions from the underlying platform APIs, and maybe a cross-platform SafeAreaView could be built on top of them for simpler use cases. So I decided to work on 2 new components:
LayoutRegionView: based onUIView.LayoutRegionon iOS, withcornerAdaptationsupport, andbar,margins,safeArea,readableContentregions.WindowInsetsView: based onWindowInsetson Android, withsystemBars,statusBars,navigationBars,captionBar,displayCutout,ime,systemGestures,mandatorySystemGestures,tappableElementinsets.
The LayoutRegionView can be used as follows:
<LayoutRegionView
region="safeArea"
cornerAdaptation="horizontal"
edges={{ top: 'additive', start: 'additive' }}
>
{/* content */}
</LayoutRegionView>
The WindowInsetsView can be used as follows:
<WindowInsetsView
types={['systemBars', 'displayCutout']}
edges={{ top: 'additive', bottom: 'additive' }}
>
{/* content */}
</WindowInsetsView>
Both of these components accept:
edges: to control which edges get the insets applied as padding, and whether they're added to the padding in style (additive) or the maximum of the inset and the padding in style is used (maximum)onInsetsChange: to get the actual inset values if we need them for calculations, instead of wrapping the content and applying padding
But exposing platform-specific insets isn't enough. We still had a set of requirements we needed to handle so these components work well with React Navigation and React Native:
- Insets should reflect the view's position automatically, e.g. a view not covered by the status bar should not get a top inset.
- Insets should stay stable during transforms to avoid jumps or stale layout.
- Insets should work inside scroll views. While scroll views on iOS have automatic insets, we still need custom handling for
cornerAdaptation. - Insets should include the translucent header and tab bar areas.
- We should be able to provide our own insets, e.g. for custom headers, tab bars etc.
For me, making it automatic was crucial. As a library, React Navigation's components could be used in many different scenarios, and they need to work well automatically without requiring users to manually tweak each case.
Compared to using react-native-safe-area-context where the insets depend on where we render SafeAreaProvider, our components should only depend on where we render the LayoutRegionView or the WindowInsetsView.


In React Navigation navigators, we render the SafeAreaProvider only at the root, as rendering it inside a screen that has transform animations would lead to jumps or incorrect insets. So we can't avoid incorrect insets in many cases.
Handling all the requirements while keeping it automatic was challenging, but we managed to achieve it with a few tricks.
There was still one more thing. On iOS, the safeArea regions also account for native navigation bars, tab bars etc. And for custom overlays, iOS supports an additionalSafeAreaInsets property on view controllers to add additional insets. But none of the inset types on Android handle headers and tab bars. So I added a custom inset type to WindowInsetsView to provide insets for our own UI elements.
To abstract these 2 mechanisms, I made an OverlayInsetsProvider component:
<OverlayInsetsProvider insets={{ top: headerHeight, bottom: tabBarHeight }}>
{/* content */}
</OverlayInsetsProvider>
I named it OverlayInsetsProvider since it provides the insets for overlays, and not only the iOS-specific safeArea region.
This component sounds similar to SafeAreaProvider, but the main difference is that a SafeAreaProvider is also where the insets are measured, so your actual component may not be overlapped by the status bar, but it'll still get the insets if the SafeAreaProvider is overlapped by the status bar. With OverlayInsetsProvider, the insets still depend on where the component itself is located.
How it affects the API
Currently the main way to handle translucent header and tab bar insets are the useHeaderHeight and useBottomTabBarHeight hooks. They are quite flexible from an API perspective, but:
- They are coupled to the concept of headers and tab bars and don't fit with other type of UI elements.
- They don't work well with native headers and tab bars since we don't know the height upfront.
- We still need to handle safe area insets separately for other screen edges.
The LayoutRegionView and WindowInsetsView components work for both native and custom UI elements as well as status bar, notch, etc. With a cross-platform abstraction over them, they can provide a unified way to handle insets across a wide-range of cases.
And since we're using built-in APIs on iOS, this also means that the contentInsetAdjustmentBehavior="automatic" prop on ScrollView will also work with custom headers and tab bars as well as JS-only navigators.
One thing we still need to figure out is the best way to provide insets to components such as FlatList on Android, where we can't wrap the content to provide insets. Perhaps using ListHeaderComponent and ListFooterComponent with the appropriate insets could be a solution.
My ideal API would be support for something like CSS env() variables in React Native, so we could do something like:
<View
style={{
paddingTop: env('safe-area-inset-top'),
paddingBottom: env('safe-area-inset-bottom'),
}}
>
{/* content */}
</View>
It could be combined with calc(), max() etc. for more complex use cases. This also works well with components like FlatList since these are just normal styles that all components would support.
But for now, we have to work with the limitations of React Native. Hopefully the lower-level primitives like LayoutRegionView and WindowInsetsView will make it easier to build UIs that feel at home on each platform.
Future plans
The React Native Screens team is also working on a SafeAreaView component for iOS and Android. But it doesn't handle all the cases we need. So we plan to work with them to port our approach to React Native Screens instead, so there can be a unified solution for handling safe areas. The SafeAreaView component can then be an abstraction on top of LayoutRegionView and WindowInsetsView.