You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: better keyboardVerticalOffset for KeyboardAvoidingView explanation (#890)
## 📜 Description
Added a better explanation of what `keyboardVerticalOffset` does and
when to use it.
## 💡 Motivation and Context
Clearer documentation -> less bug reports 😎
Closes#887
## 📢 Changelog
<!-- High level overview of important changes -->
<!-- For example: fixed status bar manipulation; added new types
declarations; -->
<!-- If your changes don't affect one of platform/language below - then
remove this platform/language -->
### Docs
- added better explanation of `keyboardVerticalOffset property`;
## 🤔 How Has This Been Tested?
Tested via preview.
## 📸 Screenshots (if appropriate):
<img width="1003" alt="image"
src="https://github.com/user-attachments/assets/19a63ae9-305d-4828-be4a-a8af69444e11"
/>
## 📝 Checklist
- [x] CI successfully passed
- [x] I added new mocks and corresponding unit-tests if library API was
changed
Copy file name to clipboardExpand all lines: docs/docs/api/components/keyboard-avoiding-view.mdx
+54-1Lines changed: 54 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -132,4 +132,57 @@ A boolean prop indicating whether `KeyboardAvoidingView` is enabled or disabled.
132
132
133
133
### `keyboardVerticalOffset`
134
134
135
-
This is the distance between the top of the user screen and the react native view, may be non-zero in some use cases. Default is `0`.
135
+
This is the distance between the top of the user screen and the react native view This is particularly useful when there are fixed headers, navigation bars, or other UI elements at the top of the screen. Default is `0`.
<summary>When to use `keyboardVerticalOffset`?</summary>
141
+
142
+
You should use `keyboardVerticalOffset` in the following scenarios:
143
+
144
+
-**Navigation Bars / Headers** - If your screen is inside a `Stack.Navigator` from `react-navigation`, the header height should be compensated using `keyboardVerticalOffset`:
-**Custom Toolbars or Fixed Elements at the Top** - If your app has a fixed toolbar, status bar, or other UI elements at the top, you should offset accordingly.
165
+
166
+
-**Modal Screens with Different Layouts** - When using `KeyboardAvoidingView` inside a `Modal`, you may need to manually define the vertical offset to account for the modal’s positioning.
167
+
168
+
Below shown a visual representation of `keyboardVerticalOffset`:
169
+
170
+
<KeyboardVerticalOffset />
171
+
172
+
:::warning Translucent `StatusBar`
173
+
If you are using translucent `StatusBar` on Android, then `StatusBar` padding gets handled by `react-navigation` automatically and it will include safe-area padding in `useHeaderHeight` (i. e. `StatusBar` height will be included in the returned value and it will match iOS behavior).
174
+
175
+
If you are not using translucent `StatusBar`, then you need to include `StatusBar` height yourself:
0 commit comments