Safe Areas and the Keyboard
Sprout's first screen looks fine in the simulator. On a real phone, the title hides behind the camera notch, and on the "Add plant" form the keyboard covers the Save button. Web pages rarely face either problem. Phones face both every day.
The rule
Pad for the notch; lift the form above the keyboard.
Safe areas. Phones have notches, rounded corners, status bars and home indicators. The safe area is the part of the screen nothing covers. Wrap each screen's content so it stays inside:
import { SafeAreaView } from 'react-native-safe-area-context';
export default function HomeScreen() {
return (
<SafeAreaView style={{ flex: 1 }}>
<Text>My plants</Text>
</SafeAreaView>
);
}The react-native-safe-area-context library works on both iOS and Android and needs a SafeAreaProvider near the root of the app (Expo Router's template already includes it). For finer control, the useSafeAreaInsets() hook returns the exact padding for each edge. React Native's own built-in SafeAreaView only works on iOS and is deprecated, so prefer the library.
The keyboard. When a TextInput gets focus, the keyboard slides up over the bottom of the screen. KeyboardAvoidingView moves or shrinks its content to make room:
import { KeyboardAvoidingView, Platform } from 'react-native';
<KeyboardAvoidingView
style={{ flex: 1 }}
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
>
{/* name input, interval input, Save button */}
</KeyboardAvoidingView>behavior decides how it makes room: padding adds space at the bottom, height shrinks the view. iOS usually works best with padding. Android often resizes the window itself, which is why its setting differs. If a header sits above the form, keyboardVerticalOffset tells the view how much to allow for it.