Skip to content

Commit 90f12bb

Browse files
committed
Document headerBackButtonDisplayMode
1 parent 89cc4b8 commit 90f12bb

File tree

3 files changed

+39
-8
lines changed

3 files changed

+39
-8
lines changed

versioned_docs/version-7.x/native-stack-navigator.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,21 @@ This will have no effect on the first screen in the stack.
176176

177177
#### `headerBackTitle`
178178

179-
Title string used by the back button on iOS. Defaults to the previous scene's title, or "Back" if there's not enough space. Use `headerBackTitleVisible: false` to hide it.
179+
Title string used by the back button on iOS. Defaults to the previous scene's title, or "Back" if there's not enough space. Use `headerBackButtonDisplayMode` to customize the behavior.
180180

181181
Only supported on iOS.
182182

183183
<img src="/assets/7.x/native-stack/headerBackTitle.jpeg" width="500" alt="Header back title" />
184184

185-
#### `headerBackTitleVisible`
185+
#### `headerBackButtonDisplayMode`
186186

187-
Whether the back button title should be visible or not.
187+
How the back button displays icon and title.
188+
189+
Supported values:
190+
191+
- `default`: Displays one of the following depending on the available space: previous screen's title, generic title (e.g. 'Back') or no title (only icon).
192+
- `generic`: Displays one of the following depending on the available space: generic title (e.g. 'Back') or no title (only icon). iOS >= 14 only, falls back to "default" on older iOS versions.
193+
- `minimal`: Always displays only the icon without a title.
188194

189195
Only supported on iOS.
190196

versioned_docs/version-7.x/stack-navigator.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -435,16 +435,24 @@ Function which returns a React Element to display custom image in header's back
435435

436436
#### `headerBackTitle`
437437

438-
Title string used by the back button on iOS. Defaults to the previous scene's `headerTitle`.
439-
440-
#### `headerBackTitleVisible`
441-
442-
A reasonable default is supplied for whether the back button title should be visible or not, but if you want to override that you can use `true` or `false` in this option.
438+
Title string used by the back button on iOS. Defaults to the previous scene's title. Use `headerBackButtonDisplayMode` to customize the behavior.
443439

444440
#### `headerTruncatedBackTitle`
445441

446442
Title string used by the back button when `headerBackTitle` doesn't fit on the screen. `"Back"` by default.
447443

444+
#### `headerBackButtonDisplayMode`
445+
446+
How the back button displays icon and title.
447+
448+
Supported values:
449+
450+
- `default`: Displays one of the following depending on the available space: previous screen's title, generic title (e.g. 'Back') or no title (only icon).
451+
- `generic`: Displays one of the following depending on the available space: generic title (e.g. 'Back') or no title (only icon).
452+
- `minimal`: Always displays only the icon without a title.
453+
454+
Defaults to `default` on iOS, and `minimal` on Android.
455+
448456
#### `headerBackTitleStyle`
449457

450458
Style object for the back title.

versioned_docs/version-7.x/upgrading-from-6.x.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,23 @@ Now, screens pushed on top of modals are automatically shown as modals to avoid
241241
242242
See [Stack Navigator](stack-navigator.md#presentation) and [Native Stack Navigator](native-stack-navigator.md#presentation) docs for usage.
243243
244+
#### `headerBackTitleVisible` is removed in favor of `headerBackButtonDisplayMode` in Stack and Native Stack navigators
245+
246+
Previously, `headerBackTitleVisible` could be used to control whether the back button title is shown in the header. It's now removed in favor of `headerBackButtonDisplayMode` which provides more flexibility.
247+
248+
The previous behavior can be achieved by setting `headerBackButtonDisplayMode` to `default` and `minimal` for showing and hiding the back button title respectively:
249+
250+
```diff lang=js
251+
<Stack.Screen
252+
name="Details"
253+
component={DetailsScreen}
254+
options={{
255+
- headerBackTitleVisible: false,
256+
+ headerBackButtonDisplayMode: 'minimal',
257+
}}
258+
/>
259+
```
260+
244261
#### `animationEnabled` option is removed in favor of `animation` option in Stack Navigator
245262
246263
Previously, `animationEnabled: false` was used to disable the animation for the screen transition in Stack Navigator.

0 commit comments

Comments
 (0)