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
feat: add mode prop for KeyboardAwareScrollView (#1420)
## 📜 Description
Added `mode` prop to `KeyboardAwareScrollView`.
## 💡 Motivation and Context
It seems that increasing `height` of fake view in
`KeyboardAwareScrollView` sometimes is a desired behavior.
Even though I think like it's still better to avoid - obviously by
performing such a significant refactor we introduce breaking changes and
to simplify migration for other developers I added `mode` prop
compatibility.
I would like to dive deeper and see if we can use `translate` approach
for such things to make performance better (i. e. sheets etc.), but this
is a big research and for now I just want to give an ability to use old
behavior 🤞
Closes#1414
Potentially
#1368
## 📢 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 -->
### JS
- add `mode` property to `KeyboardAwareScrollView`;
### Docs
- mention in blogpost new behavior;
- add new property description to docs page.
## 🤔 How Has This Been Tested?
Tested via e2e tests in CI.
## 📝 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/blog/2026-03-16-release-1-21/index.mdx
+23Lines changed: 23 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -288,6 +288,29 @@ Starting from `1.21.0`, `KeyboardAwareScrollView` uses `contentInset` on iOS and
288
288
289
289
This is a behavioral improvement — your existing `KeyboardAwareScrollView` usage needs no changes.
290
290
291
+
### Opting back into layout-based spacing with `mode="layout"`
292
+
293
+
There is, however, one class of UI where the old behavior was actually the _desired_ outcome: layouts that **intentionally rely on flex redistribution**. If you have a form where layout re-distribution helps to put form in correct position, the inset approach won't do that — it extends scroll space without touching layout.
294
+
295
+
For these cases, `1.21.0` ships a new `mode` prop:
|`"layout"`| Spacer `View` appended as last child | ✅ flex redistributes |
311
+
312
+
I intentionally made `"insets"` default to deliver best possible performance, but if your layout depends on layout changes - you may want to use `mode="layout"`.
313
+
291
314
## Other notable changes
292
315
293
316
Beyond the headline features, this release includes a couple of smaller but important additions.
Copy file name to clipboardExpand all lines: docs/docs/api/components/keyboard-aware-scroll-view.mdx
+28Lines changed: 28 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -116,6 +116,34 @@ If you have _**sticky elements**_ above the keyboard and want to extend the keyb
116
116
This property acts as [extraScrollHeight](https://github.com/APSL/react-native-keyboard-aware-scroll-view/tree/9eee405f7b3e261faf86a0fc8e495288d91c853e?tab=readme-ov-file#props) from original [react-native-keyboard-aware-scroll-view](https://github.com/APSL/react-native-keyboard-aware-scroll-view) package.
117
117
:::
118
118
119
+
### `mode`
120
+
121
+
Controls how keyboard space is created at the bottom of the `ScrollView`. Default is `"insets"`.
|`"insets"`| Extends the scrollable area via `contentInset` (iOS) and `ClippingScrollView` (Android). Content layout is never modified — no layout reflows occur during keyboard animation. **Recommended for most use cases.**|
126
+
|`"layout"`| Appends a spacer `View` as the last child of the `ScrollView`. The spacer participates in layout, so flex-based arrangements (e.g. `justifyContent: "space-between"`, `gap`) reflow naturally when the keyboard appears. |
127
+
128
+
:::tip When to use `mode="layout"`?
129
+
If your `ScrollView` content relies on flex distribution — for example a form where a submit button should stay visually pinned to the bottom of the available space — use `mode="layout"` so the layout engine redistributes space when the keyboard appears.
`mode="insets"` was introduced in `1.21.0` and is the default. `mode="layout"` restores the pre-`1.21.0` spacer-based behavior for cases where layout reflow is intentional.
Copy file name to clipboardExpand all lines: docs/versioned_docs/version-1.21.0/api/components/keyboard-aware-scroll-view.mdx
+28Lines changed: 28 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -116,6 +116,34 @@ If you have _**sticky elements**_ above the keyboard and want to extend the keyb
116
116
This property acts as [extraScrollHeight](https://github.com/APSL/react-native-keyboard-aware-scroll-view/tree/9eee405f7b3e261faf86a0fc8e495288d91c853e?tab=readme-ov-file#props) from original [react-native-keyboard-aware-scroll-view](https://github.com/APSL/react-native-keyboard-aware-scroll-view) package.
117
117
:::
118
118
119
+
### `mode`
120
+
121
+
Controls how keyboard space is created at the bottom of the `ScrollView`. Default is `"insets"`.
|`"insets"`| Extends the scrollable area via `contentInset` (iOS) and `ClippingScrollView` (Android). Content layout is never modified — no layout reflows occur during keyboard animation. **Recommended for most use cases.**|
126
+
|`"layout"`| Appends a spacer `View` as the last child of the `ScrollView`. The spacer participates in layout, so flex-based arrangements (e.g. `justifyContent: "space-between"`, `gap`) reflow naturally when the keyboard appears. |
127
+
128
+
:::tip When to use `mode="layout"`?
129
+
If your `ScrollView` content relies on flex distribution — for example a form where a submit button should stay visually pinned to the bottom of the available space — use `mode="layout"` so the layout engine redistributes space when the keyboard appears.
`mode="insets"` was introduced in `1.21.0` and is the default. `mode="layout"` restores the pre-`1.21.0` spacer-based behavior for cases where layout reflow is intentional.
/** The distance between the keyboard and the caret inside a focused `TextInput` when the keyboard is shown. Default is `0`. */
6
8
bottomOffset?: number;
@@ -10,6 +12,15 @@ export type KeyboardAwareScrollViewProps = {
10
12
enabled?: boolean;
11
13
/** Adjusting the bottom spacing of KeyboardAwareScrollView. Default is `0`. */
12
14
extraKeyboardSpace?: number;
15
+
/**
16
+
* Controls how keyboard space is created at the bottom of the `ScrollView`.
17
+
*
18
+
* - `"insets"` *(default)*: Extends the scrollable area via `contentInset` (iOS) and `ClippingScrollView` (Android). No layout reflow occurs — content positions remain stable during keyboard animation. Recommended for most use cases.
19
+
* - `"layout"`: Appends a spacer `View` as the last child of the `ScrollView`. The spacer participates in layout, so flex-based arrangements (e.g. `justifyContent: "space-between"`, `gap`) reflow naturally when the keyboard appears. Use this when you need content to physically rearrange around the keyboard space.
20
+
*
21
+
* Default is `"insets"`.
22
+
*/
23
+
mode?: KeyboardAwareScrollViewMode;
13
24
/** Custom component for `ScrollView`. Default is `ScrollView`. */
0 commit comments