KeyboardAvoidingView is a component that automatically adjusts its height, position, or bottom padding based on the keyboard height to prevent the keyboard from covering important UI elements.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/facebook/react-native/llms.txt
Use this file to discover all available pages before exploring further.
Usage
Props
Specifies how the KeyboardAvoidingView should react to the keyboard appearance.
height: Adjusts the view’s height by shrinking it when the keyboard appearsposition: Moves the entire view up using absolute positioningpadding: Adds bottom padding to push content up
'padding' on iOS and 'height' on Android for best results.Style of the content container when
behavior is 'position'. This wraps your children when using position mode.Controls whether this KeyboardAvoidingView instance should take effect. Useful when multiple instances are on screen.
Distance in pixels between the top of the user screen and the React Native view. Use this to account for navigation bars or other UI elements.
Style applied to the KeyboardAvoidingView container.
Behavior Modes Explained
Height Mode
Reduces the view’s height to avoid the keyboard. Best for Android.Position Mode
Moves the view up when the keyboard appears. Useful for centered content.Padding Mode
Adds bottom padding to push content up. Best for iOS with ScrollView.Platform Differences
iOS
On iOS, the component listens tokeyboardWillShow and keyboardWillHide events with animated transitions.
Android
On Android, the component listens tokeyboardDidShow and keyboardDidHide events.
Common Patterns
With ScrollView
Form at Bottom of Screen
Chat Input
Troubleshooting
If the keyboard behavior isn’t working correctly:- Ensure
KeyboardAvoidingViewhasflex: 1or a defined height - Adjust
keyboardVerticalOffsetto account for navigation bars - Try different
behaviorvalues for your use case - On Android, ensure
android:windowSoftInputModeis set toadjustResizein AndroidManifest.xml