KeyboardAvoidingView

A container that moves or shrinks its content when the on-screen keyboard opens, so inputs and buttons stay visible. Use behavior="padding" on iOS, pass keyboardVerticalOffset for any header above it, and pair it with a ScrollView using keyboardShouldPersistTaps="handled".

Minimal example

tsx
<KeyboardAvoidingView style={{ flex: 1 }} behavior={Platform.OS === "ios" ? "padding" : "height"}>
  <ScrollView keyboardShouldPersistTaps="handled">{form}</ScrollView>
</KeyboardAvoidingView>

Learn this concept

Lesson 4.1 · React Native screen layout

Used in exercises

Exercise 4.7 · API client and auth screens
Prerequisite conceptsCore components
RelatedSafe area