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
Copy file name to clipboardExpand all lines: versioned_docs/version-6.x/bottom-tab-navigator.md
+79-71Lines changed: 79 additions & 71 deletions
Original file line number
Diff line number
Diff line change
@@ -65,10 +65,6 @@ It supports the following values:
65
65
-`history` - return to last visited tab
66
66
-`none` - do not handle back button
67
67
68
-
#### `lazy`
69
-
70
-
Defaults to `true`. If `false`, all tabs are rendered immediately. When `true`, tabs are rendered only when they are made active for the first time. Note: tabs are **not** re-rendered upon subsequent visits.
71
-
72
68
#### `detachInactiveScreens`
73
69
74
70
Boolean used to indicate whether inactive screens should be detached from the view hierarchy to save memory. Make sure to call `enableScreens` from [react-native-screens](https://github.com/software-mansion/react-native-screens) to make it work. Defaults to `true`.
@@ -166,82 +162,105 @@ function MyTabBar({ navigation }) {
166
162
}
167
163
```
168
164
169
-
#### `tabBarOptions`
165
+
### Options
166
+
167
+
The following [options](screen-options.md) can be used to configure the screens in the navigator:
168
+
169
+
#### `title`
170
+
171
+
Generic title that can be used as a fallback for `headerTitle` and `tabBarLabel`.
172
+
173
+
#### `tabBarLabel`
174
+
175
+
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 `tabBarOptions.showLabel` in the previous section.
176
+
177
+
#### `tabBarShowLabel`
178
+
179
+
Whether the tab label should be visible. Defaults to `true`.
180
+
181
+
### `tabBarLabelPosition`
170
182
171
-
An object containing the props for the default tab bar component. If you're using a custom tab bar, these will be passed as props to the tab bar and you can handle them.
183
+
Whether the label is shown below the icon or beside the icon.
172
184
173
-
It can contain the following properties:
185
+
-`below-icon`: the label is shown below the icon (typical for iPhones)
186
+
-`beside-icon` the label is shown next to the icon (typical for iPad)
174
187
175
-
##### `activeTintColor`
188
+
By default, the position is chosen automatically based on device width.
176
189
177
-
Label and icon color of the active tab item.
190
+
#### `tabBarLabelStyle`
178
191
179
-
##### `inactiveTintColor`
192
+
Style object for the tab label.
180
193
181
-
Label and icon color of the inactive tab item.
194
+
#### `tabBarIcon`
182
195
183
-
##### `activeBackgroundColor`
196
+
Function that given `{ focused: boolean, color: string, size: number }` returns a React.Node, to display in the tab bar.
184
197
185
-
Background color of the active tab item.
198
+
#### `tabBarIconStyle`
186
199
187
-
##### `inactiveBackgroundColor`
200
+
Style object for the tab icon.
188
201
189
-
Background color of the inactive tab item.
202
+
#### `tabBarBadge`
190
203
191
-
##### `tabStyle`
204
+
Text to show in a badge on the tab icon. Accepts a `string` or a `number`.
192
205
193
-
Style object for the tab item.
206
+
#### `tabBarBadgeStyle`
194
207
195
-
##### `showLabel`
208
+
Style for the badge on the tab icon. You can specify a background color or text color here.
196
209
197
-
Whether to show label for tab, default is `true`.
210
+
#### `tabBarAccessibilityLabel`
198
211
199
-
##### `labelStyle`
212
+
Accessibility label for the tab button. This is read by the screen reader when the user taps the tab. It's recommended to set this if you don't have a label for the tab.
200
213
201
-
Style object for the tab label text.
214
+
#### `tabBarTestID`
202
215
203
-
##### `labelPosition`
216
+
ID to locate this tab button in tests.
217
+
218
+
#### `tabBarButton`
219
+
220
+
Function which returns a React element to render as the tab bar button. It wraps the icon and label. Renders `Pressable` by default.
204
221
205
-
Whether the label is rendered below the icon or beside the icon. Possible values are:
By default, in `vertical` orientation (portrait mode), label is rendered below the icon and in `horizontal` orientation (landscape mode)., it's rendered beside the icon.
228
+
#### `tabBarActiveTintColor`
211
229
212
-
##### `adaptive`
230
+
Color for the icon and label in the active tab.
213
231
214
-
Should the tab icons and labels alignment change based on screen size? Defaults to `true`. If `false`, tab icons and labels align vertically all the time (`labelPosition: 'below-icon'`). When `true`, tab icons and labels align horizontally on tablets (`labelPosition: 'beside-icon'`).
232
+
#### `tabBarInactiveTintColor`
215
233
216
-
##### `allowFontScaling`
234
+
Color for the icon and label in the inactive tabs.
217
235
218
-
Whether label font should scale to respect Text Size accessibility settings, default is true.
236
+
#### `tabBarActiveBackgroundColor`
219
237
220
-
##### `keyboardHidesTabBar`
238
+
Background color for the active tab.
221
239
222
-
Whether the tab bar is hidden when the keyboard opens. Defaults to `false`.
240
+
#### `tabBarInactiveBackgroundColor`
223
241
224
-
##### `safeAreaInsets`
242
+
Background color for the inactive tabs.
225
243
226
-
Safe area insets for the screen. This is used to avoid elements like notch and system navigation bar. By default, the device's safe area insets are automatically detected. You can override the behavior with this option.
244
+
##### `tabBarHideOnKeyboard`
227
245
228
-
Takes an object containing following optional properties:
246
+
Whether the tab bar is hidden when the keyboard opens. Defaults to `false`.
229
247
230
-
-`top` - _number_ - The value of the top inset, e.g. area containing the status bar and notch.
231
-
-`right` - _number_ - The value of the left inset.
232
-
-`bottom` - _number_ - The value of the bottom inset, e.g. area navigation bar on bottom.
233
-
-`left`. - _number_ - The value of the right inset.
248
+
##### `tabBarItemStyle`
234
249
235
-
##### `style`
250
+
Style object for the tab item container.
251
+
252
+
##### `tabBarStyle`
236
253
237
254
Style object for the tab bar. You can configure styles such as background color here.
238
255
239
256
To show your screen under the tab bar, you can set the `position` style to absolute:
240
257
241
258
```js
242
-
style: {
243
-
position:'absolute';
244
-
}
259
+
<Tab.Navigator
260
+
screenOptions={{
261
+
tabBarStyle: { position:'absolute' },
262
+
}}
263
+
>
245
264
```
246
265
247
266
You also might need to add a bottom margin to your content if you have a absolutely positioned tab bar. React Navigation won't do it automatically.
@@ -270,41 +289,30 @@ import { useBottomTabBarHeight } from '@react-navigation/bottom-tabs';
270
289
consttabBarHeight=useBottomTabBarHeight();
271
290
```
272
291
273
-
###Options
292
+
#### `tabBarBackground`
274
293
275
-
The following [options](screen-options.md) can be used to configure the screens in the navigator:
294
+
Function which returns a React Element to use as background for the tab bar. You could render an image, a gradient, blur view etc.:
276
295
277
-
#### `title`
278
-
279
-
Generic title that can be used as a fallback for `headerTitle` and `tabBarLabel`.
280
-
281
-
#### `tabBarIcon`
282
-
283
-
Function that given `{ focused: boolean, color: string, size: number }` returns a React.Node, to display in the tab bar.
284
-
285
-
#### `tabBarLabel`
286
-
287
-
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 `tabBarOptions.showLabel` in the previous section.
288
-
289
-
#### `tabBarBadge`
290
-
291
-
Text to show in a badge on the tab icon. Accepts a `string` or a `number`.
292
-
293
-
#### `tabBarBadgeStyle`
294
-
295
-
Style for the badge on the tab icon. You can specify a background color or text color here.
296
-
297
-
#### `tabBarButton`
296
+
```js
297
+
import { BlurView } from'expo-blur';
298
298
299
-
Function which returns a React element to render as the tab bar button. It wraps the icon and label and implements `onPress`. Renders `TouchableWithoutFeedback` by default. `tabBarButton: props => <TouchableOpacity {...props} />` would use `TouchableOpacity` instead.
Accessibility label for the tab button. This is read by the screen reader when the user taps the tab. It's recommended to set this if you don't have a label for the tab.
311
+
When using `BlurView`, make sure to set `position: 'absolute'` in `tabBarStyle` as well. You'd also need to use `useBottomTabBarHeight()` to add a bottom padding to your content.
304
312
305
-
#### `tabBarTestID`
313
+
#### `lazy`
306
314
307
-
ID to locate this tab button in tests.
315
+
Whether this screens should render the first time it's accessed. Defaults to `true`. Set it to `false` if you want to render the screen on initial render.
0 commit comments