SafeAreaView is a React Native component that ensures content is rendered within the safe boundaries of a device screen, avoiding notches, status bars, rounded corners, and home indicator areas.
SafeAreaView works similarly to a regular View but applies padding automatically to match the safe area boundaries of the device.
// Import SafeAreaView from react-native
import { SafeAreaView, Text } from "react-native";
const App = () => {
return (
Hello Safe Area
);
};
export default App;
The text is displayed inside the safe boundaries of the device screen. On phones with notches or system UI areas, the content automatically avoids overlapping those regions.
Click the button below to see how SafeAreaView protects your content from being hidden behind the device notch.
This is the main content of your app.
Notice how the header position changes relative to the black notch at the top.
With SafeAreaView: Content is pushed down.
Without: Header is hidden behind the notch.
// SafeAreaView with background color and centered content
import { SafeAreaView, Text, StyleSheet } from "react-native";
const App = () => {
return (
<SafeAreaView style={styles.container}>
<Text style={styles.text}>Safe Area Content</Text>
</SafeAreaView>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "center",
alignItems: "center",
backgroundColor: "#eef5ff"
},
text: {
fontSize: 18
}
});
export default App;
SafeAreaViewflex: 1 for full-height layoutsStyleSheet for consistent stylingSafeAreaView and a headerSafeAreaView