Skip to content

Commit 9642619

Browse files
authored
Merge pull request react-navigation#92 from jozan/patch-2
Document forceInset prop
2 parents e19a68e + 91f1bc2 commit 9642619

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

docs/handling-iphonex.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default createStackNavigator({
3030

3131
![Text hidden by iPhoneX UI elements](./assets/iphoneX/02-iphonex-content-hidden.png)
3232

33-
To fix this issue you can wrap your content in a `SafeAreaView`, which can be imported from either `react-native` or `react-navigation`.
33+
To fix this issue you can wrap your content in a `SafeAreaView`, which can be imported from `react-navigation`.
3434

3535
```javascript
3636
import { SafeAreaView } from 'react-navigation';
@@ -68,3 +68,22 @@ To fix this you can, once again, wrap your content in a `SafeAreaView`. This wil
6868
In conclusion, use the `SafeAreaView` component on the screens you register with a React Navigation navigator.
6969

7070
A [Snack](https://snack.expo.io/BJ6-M8pEG) is available with the code used in this overview.
71+
72+
## Use `forceInset` to get more control
73+
74+
In some cases you might need more control which paddings are applied. For example you can remove bottom padding by passing `forceInset` prop to `SafeAreaView`.
75+
76+
```javascript
77+
<SafeAreaView style={styles.container} forceInset={{ bottom: 'never' }}>
78+
<Text style={styles.paragraph}>
79+
This is top text.
80+
</Text>
81+
<Text style={styles.paragraph}>
82+
This is bottom text.
83+
</Text>
84+
</SafeAreaView>
85+
```
86+
87+
`forceInset` takes an object with the keys `top | bottom | left | right | vertical | horizontal` and the values `'always' | 'never'`. Or you can override the padding altogether by passing an integer.
88+
89+
There is also a [Snack](https://snack.expo.io/@jozan/react-navigation-docs:-safeareaview-demo) available to demonstrate how `forceInset` behaves.

0 commit comments

Comments
 (0)