useSafeAreaInsets
Returns the safe area insets of the nearest provider. This allows manipulating the inset values from JavaScript. Note that insets are not updated synchronously so it might cause a slight delay for example when rotating the screen.
Object with { top: number, right: number, bottom: number, left: number }.
Example
import { useSafeAreaInsets } from 'react-native-safe-area-context';
function HookComponent() {
const insets = useSafeAreaInsets();
return <View style={{ paddingBottom: Math.max(insets.bottom, 16) }} />;
}
Options
cornerAdaptation
Optional, vertical or horizontal.
Returns safe area insets enlarged where the display's rounded corners reach past the regular safe area. vertical enlarges the top and bottom insets, horizontal enlarges the left and right insets. Without this option the regular insets are returned.
This is useful on displays where the regular safe area does not cover the rounded corners, for example when the status bar is not along the top edge. Content laid out with the regular insets can then be clipped by the corners.
function Header() {
const insets = useSafeAreaInsets({ cornerAdaptation: 'vertical' });
return <View style={{ paddingTop: insets.top }} />;
}
horizontal is not a no-op on regular phones. An iPhone 18 Pro in portrait has no regular left or right inset, but its corners give left: 18, right: 18.
There is no option that adapts both axes at once because UIKit's UIViewLayoutRegionAdaptivityAxis is a single choice of none, horizontal or vertical. If you need it, combine the two results per edge, for example top from vertical and left from horizontal.
- iOS 26+: uses
edgeInsets(for: .safeArea(cornerAdaptation:))measured on theSafeAreaProviderview. UIKit computes the value from the provider's position and size, so it can be smaller than the window's value for a short or narrow provider. - Android 12+ (API 31): computed from the rounded corners the window reports, with the rule UIKit applies. For each corner of radius
R, the inset isr × (1 − √2⁄2)withr = min(R − max(dx, dy), width / 2, height / 2), wheredxanddyare the provider's distances from the two screen edges meeting at that corner. The edge inset is the larger of that value and the regular inset. - Older iOS and Android versions, and web: same as the regular insets.
Components that use only the regular insets do not re-render when only the corner-adapted insets change. Both variants are also available from SafeAreaCornerAdaptedInsetsContext as { vertical, horizontal }.