Skip to content

Commit b995543

Browse files
committed
Update docs according to latest changes
1 parent c7b1810 commit b995543

12 files changed

Lines changed: 399 additions & 53 deletions

‎versioned_docs/version-7.x/bottom-tab-navigator.md‎

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,16 @@ function MyTabBar({ state, descriptors, navigation }) {
158158
type: 'tabPress',
159159
target: route.key,
160160
canPreventDefault: true,
161+
data: {
162+
behavior: {
163+
scrollToTop:
164+
isFocused &&
165+
options.tabBarRepeatedPressBehavior?.scrollToTop !== false,
166+
popToTop:
167+
isFocused &&
168+
options.tabBarRepeatedPressBehavior?.popToTop !== false,
169+
},
170+
},
161171
});
162172

163173
if (!isFocused && !event.defaultPrevented) {
@@ -258,11 +268,17 @@ Generic title that can be used as a fallback for `headerTitle` and `tabBarLabel`
258268
259269
#### `tabBarLabel`
260270
261-
Title string of a tab displayed in the tab bar or a function that given `{ focused: boolean, color: string }` returns a React.Node, to display in tab bar. When undefined, scene `title` is used. To hide, see `tabBarShowLabel`.
271+
Title string of a tab displayed in the tab bar or a function that given `{ focused: boolean, color: string }` returns a React.Node, to display in tab bar. When undefined, scene `title` is used. To hide, see [`tabBarLabelVisibilityMode`](#tabbarlabelvisibilitymode).
272+
273+
#### `tabBarLabelVisibilityMode`
274+
275+
The label visibility mode for the tab bar items. Supported values are:
262276
263-
#### `tabBarShowLabel`
277+
- `auto` - labels are shown automatically
278+
- `labeled` - labels are always shown
279+
- `unlabeled` - labels are never shown
264280
265-
Whether the tab label should be visible. Defaults to `true`.
281+
Defaults to `auto`.
266282
267283
#### `tabBarLabelPosition`
268284
@@ -559,6 +575,26 @@ Boolean indicating whether any nested stack should be popped to the top of the s
559575
560576
It only works when there is a stack navigator (e.g. [stack navigator](stack-navigator.md) or [native stack navigator](native-stack-navigator.md)) nested under the tab navigator.
561577
578+
#### `tabBarRepeatedPressBehavior`
579+
580+
Behavior when the focused tab is pressed again. Available properties are:
581+
582+
- `scrollToTop` - whether to scroll the first scroll view in the screen to the top
583+
- `popToTop` - whether to pop a nested stack to its first screen
584+
585+
Both properties default to `true`.
586+
587+
Example:
588+
589+
```js
590+
tabBarRepeatedPressBehavior: {
591+
scrollToTop: false,
592+
popToTop: false
593+
},
594+
```
595+
596+
For scroll to top behavior to work, make sure to use [`useScrollToTop`](use-scroll-to-top.md) in your screen.
597+
562598
#### `sceneStyle`
563599
564600
Style object for the component wrapping the screen content.
@@ -624,8 +660,17 @@ This event is fired when the user presses the tab button for the current screen
624660
625661
- If the tab is not focused, tab press will focus that tab
626662
- If the tab is already focused:
627-
- If the screen for the tab renders a scroll view, you can use [`useScrollToTop`](use-scroll-to-top.md) to scroll it to top
628-
- If the screen for the tab renders a stack navigator, a `popToTop` action is performed on the stack
663+
- If the screen for the tab renders a scroll view, it can be scrolled to the top
664+
- If the screen for the tab renders a stack navigator, it can be popped to the top
665+
666+
See [`tabBarRepeatedPressBehavior`](#tabbarrepeatedpressbehavior) for more details.
667+
668+
For the built-in tab bar, the `behavior` object in `e.data` has the following properties:
669+
670+
- `scrollToTop` - whether the screen should scroll to the top
671+
- `popToTop` - whether a nested stack should pop to its first screen
672+
673+
Consumers of this event can use these properties to determine if they should perform these actions.
629674
630675
To prevent the default behavior, you can call `event.preventDefault`:
631676

‎versioned_docs/version-7.x/drawer-navigator.md‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,10 @@ drawerItemStyle: {
397397
},
398398
```
399399

400+
#### `drawerItemTestID`
401+
402+
ID to locate the drawer item in tests.
403+
400404
#### `drawerLabelStyle`
401405

402406
Style object to apply to the `Text` style inside content section which renders a label.
@@ -543,7 +547,7 @@ const MyDrawer = createDrawerNavigator({
543547
screenOptions: {
544548
drawerType: 'back',
545549
drawerStyle: { width: '100%' },
546-
overlayColor: 'transparent',
550+
overlayStyle: { backgroundColor: 'transparent' },
547551
},
548552
screens: {
549553
Home: HomeScreen,
@@ -568,9 +572,15 @@ Supported values:
568572
- `fade`
569573
- `none`
570574

571-
#### `overlayColor`
575+
#### `overlayStyle`
576+
577+
Style for the overlay on top of the content view when drawer gets open. You can use this to customize the overlay color, opacity, and other properties:
572578

573-
Color overlay to be displayed on top of the content view when drawer gets open. The opacity is animated from `0` to `1` when the drawer opens.
579+
```js
580+
overlayStyle: {
581+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
582+
}
583+
```
574584

575585
#### `sceneStyle`
576586

‎versioned_docs/version-7.x/material-top-tab-navigator.md‎

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,16 @@ function MyTabBar({ state, descriptors, navigation, position }) {
248248
type: 'tabPress',
249249
target: route.key,
250250
canPreventDefault: true,
251+
data: {
252+
behavior: {
253+
scrollToTop:
254+
isFocused &&
255+
options.tabBarRepeatedPressBehavior?.scrollToTop !== false,
256+
popToTop:
257+
isFocused &&
258+
options.tabBarRepeatedPressBehavior?.popToTop !== false,
259+
},
260+
},
251261
});
252262

253263
if (!isFocused && !event.defaultPrevented) {
@@ -511,6 +521,26 @@ By default, this renders `null`.
511521
512522
Style to apply to the view wrapping each screen. You can pass this to override some default styles such as overflow clipping.
513523
524+
#### `tabBarRepeatedPressBehavior`
525+
526+
Behavior when the focused tab is pressed again. Available properties are:
527+
528+
- `scrollToTop` - whether to scroll the first scroll view in the screen to the top
529+
- `popToTop` - whether to pop a nested stack to its first screen
530+
531+
Both properties default to `true`.
532+
533+
Example:
534+
535+
```js
536+
tabBarRepeatedPressBehavior: {
537+
scrollToTop: false,
538+
popToTop: false
539+
},
540+
```
541+
542+
For scroll to top behavior to work, make sure to use [`useScrollToTop`](use-scroll-to-top.md) in your screen.
543+
514544
### Events
515545
516546
The navigator can [emit events](navigation-events.md) on certain actions. Supported events are:
@@ -521,8 +551,17 @@ This event is fired when the user presses the tab button for the current screen
521551
522552
- If the tab is not focused, tab press will focus that tab
523553
- If the tab is already focused:
524-
- If the screen for the tab renders a scroll view, you can use [`useScrollToTop`](use-scroll-to-top.md) to scroll it to top
525-
- If the screen for the tab renders a stack navigator, a `popToTop` action is performed on the stack
554+
- If the screen for the tab renders a scroll view, it can be scrolled to the top
555+
- If the screen for the tab renders a stack navigator, it can be popped to the top
556+
557+
See [`tabBarRepeatedPressBehavior`](#tabbarrepeatedpressbehavior) for more details.
558+
559+
For the built-in tab bar, the `behavior` object in `e.data` has the following properties:
560+
561+
- `scrollToTop` - whether the screen should scroll to the top
562+
- `popToTop` - whether a nested stack should pop to its first screen
563+
564+
Consumers of this event can use these properties to determine if they should perform these actions.
526565
527566
To prevent the default behavior, you can call `event.preventDefault`:
528567

‎versioned_docs/version-7.x/native-bottom-tab-navigator.md‎

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,24 @@ Setting this to `false` doesn't remove the tab press animation, as the tab can s
522522

523523
:::
524524

525+
#### `tabBarRepeatedPressBehavior`
526+
527+
Behavior when the focused tab is pressed again. Available properties are:
528+
529+
- `scrollToTop` - whether to scroll the first scroll view in the screen to the top
530+
- `popToTop` - whether to pop a nested stack to its first screen
531+
532+
Both properties default to `true`.
533+
534+
Example:
535+
536+
```js
537+
tabBarRepeatedPressBehavior: {
538+
scrollToTop: false,
539+
popToTop: false
540+
},
541+
```
542+
525543
#### `bottomAccessory`
526544

527545
Function that returns a React element to display as an accessory view. The function receives an options object with a `placement` parameter that can be one of the following values:
@@ -584,8 +602,17 @@ This event is fired when the user presses the tab button for the current screen
584602

585603
- If the tab is not focused, tab press will focus that tab
586604
- If the tab is already focused:
587-
- If the screen for the tab renders a scroll view, you can use [`useScrollToTop`](use-scroll-to-top.md) to scroll it to top
588-
- If the screen for the tab renders a stack navigator, a `popToTop` action is performed on the stack
605+
- If the screen for the tab renders a scroll view, it can be scrolled to the top
606+
- If the screen for the tab renders a stack navigator, it can be popped to the top
607+
608+
See [`tabBarRepeatedPressBehavior`](#tabbarrepeatedpressbehavior) for more details.
609+
610+
The `data` object in the event contains the following properties:
611+
612+
- `origin` - the origin of the event, always `native`
613+
- `behavior` - An object containing:
614+
- `scrollToTop` - whether the screen should scroll to the top
615+
- `popToTop` - whether a nested stack should pop to its first screen
589616

590617
```js
591618
React.useEffect(() => {

‎versioned_docs/version-8.x/bottom-tab-navigator.md‎

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ This is the default implementation on other platforms such as web, macOS and Win
152152
- Liquid Glass effect on iOS 26+ requires your app to be built with Xcode 26 or above.
153153
- On Android, at most 5 tabs are supported with the `native` implementation. This is a limitation of the underlying native component.
154154
- The experimental `SafeAreaView` component from `react-native-screens/experimental` can be used to avoid overlapping native tab bar.
155+
- The `ScrollViewMarker` from `react-native-screens` can be used to configure scroll edge effects for native tabs.
155156

156157
## API Definition
157158

@@ -245,13 +246,30 @@ function MyTabBar({ state, descriptors, navigation }) {
245246
const isFocused = state.index === index;
246247

247248
const onPress = () => {
249+
const isRepeatedPress =
250+
isFocused && options.tabBarSelectionEnabled !== false;
251+
248252
const event = navigation.emit({
249253
type: 'tabPress',
250254
target: route.key,
251255
canPreventDefault: true,
256+
data: {
257+
behavior: {
258+
scrollToTop:
259+
isRepeatedPress &&
260+
options.tabBarRepeatedPressBehavior?.scrollToTop !== false,
261+
popToTop:
262+
isRepeatedPress &&
263+
options.tabBarRepeatedPressBehavior?.popToTop !== false,
264+
},
265+
},
252266
});
253267

254-
if (!isFocused && !event.defaultPrevented) {
268+
if (
269+
!isFocused &&
270+
!event.defaultPrevented &&
271+
options.tabBarSelectionEnabled !== false
272+
) {
255273
navigation.navigate(route.name, route.params);
256274
}
257275
};
@@ -1099,6 +1117,26 @@ Setting this to `false` doesn't remove the tab press animation, as the tab can s
10991117
11001118
:::
11011119
1120+
#### `tabBarRepeatedPressBehavior`
1121+
1122+
Behavior when the focused tab is pressed again. Available properties are:
1123+
1124+
- `scrollToTop` - whether to scroll the first scroll view in the screen to the top
1125+
- `popToTop` - whether to pop a nested stack to its first screen
1126+
1127+
Both properties default to `true`.
1128+
1129+
Example:
1130+
1131+
```js
1132+
tabBarRepeatedPressBehavior: {
1133+
scrollToTop: false,
1134+
popToTop: false
1135+
},
1136+
```
1137+
1138+
When using the [`custom` implementation](#implementation), or a [custom tab bar](#tabbar), make sure to use [`useScrollToTop`](use-scroll-to-top.md) in your screen for the scroll-to-top behavior to work.
1139+
11021140
#### `bottomAccessory`
11031141
11041142
Function that returns a React element to display as an accessory view. The function receives an options object with a `placement` parameter that can be one of the following values:
@@ -1133,23 +1171,6 @@ The content is rendered twice for both placements, but only one is visible at a
11331171
11341172
:::
11351173
1136-
#### `scrollEdgeEffects`
1137-
1138-
Configures the scroll edge effect for the _content ScrollView_ (the ScrollView that is present in first descendants chain of the Screen).
1139-
Depending on values set, it will blur the scrolling content below certain UI elements (e.g. header items, search bar) for the specified edge of the ScrollView.
1140-
When set in nested containers, i.e. Native Stack inside Native Bottom Tabs, or the other way around, the ScrollView will use only the innermost one's config.
1141-
1142-
Edge effects can be configured for each edge separately. The following values are currently supported:
1143-
1144-
- `automatic` - the automatic scroll edge effect style,
1145-
- `hard` - a scroll edge effect with a hard cutoff and dividing line,
1146-
- `soft` - a soft-edged scroll edge effect,
1147-
- `hidden` - no scroll edge effect.
1148-
1149-
Defaults to `automatic` for each edge.
1150-
1151-
Only supported with `native` implementation on iOS 26 and above.
1152-
11531174
#### `popToTopOnBlur`
11541175
11551176
Boolean indicating whether any nested stack should be popped to the top of the stack when navigating away from this tab. Defaults to `false`.
@@ -1222,8 +1243,17 @@ This event is fired when the user presses the tab button for the current screen
12221243
12231244
- If the tab is not focused, tab press will focus that tab
12241245
- If the tab is already focused:
1225-
- If the screen for the tab renders a scroll view, you can use [`useScrollToTop`](use-scroll-to-top.md) to scroll it to top
1226-
- If the screen for the tab renders a stack navigator, a `popToTop` action is performed on the stack
1246+
- If the screen for the tab renders a scroll view, it can be scrolled to the top
1247+
- If the screen for the tab renders a stack navigator, it can be popped to the top
1248+
1249+
See [`tabBarRepeatedPressBehavior`](#tabbarrepeatedpressbehavior) for more details.
1250+
1251+
The `data` object in the event contains the following properties:
1252+
1253+
- `origin` - the origin of the event, `native` for a press from the native tab bar, and omitted for [`custom` implementation](#implementation) or a [custom tab bar](#tabbar).
1254+
- `behavior` - An object containing:
1255+
- `scrollToTop` - whether the screen should scroll to the top
1256+
- `popToTop` - whether a nested stack should pop to its first screen
12271257
12281258
```js
12291259
React.useEffect(() => {

0 commit comments

Comments
 (0)