Skip to content

Commit 54b9f4f

Browse files
committed
Update bottom tab docs
1 parent d9d8bf1 commit 54b9f4f

File tree

2 files changed

+81
-72
lines changed

2 files changed

+81
-72
lines changed

versioned_docs/version-6.x/bottom-tab-navigator.md

Lines changed: 79 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ It supports the following values:
6565
- `history` - return to last visited tab
6666
- `none` - do not handle back button
6767

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-
7268
#### `detachInactiveScreens`
7369

7470
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 }) {
166162
}
167163
```
168164

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`
170182

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.
172184

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)
174187

175-
##### `activeTintColor`
188+
By default, the position is chosen automatically based on device width.
176189

177-
Label and icon color of the active tab item.
190+
#### `tabBarLabelStyle`
178191

179-
##### `inactiveTintColor`
192+
Style object for the tab label.
180193

181-
Label and icon color of the inactive tab item.
194+
#### `tabBarIcon`
182195

183-
##### `activeBackgroundColor`
196+
Function that given `{ focused: boolean, color: string, size: number }` returns a React.Node, to display in the tab bar.
184197

185-
Background color of the active tab item.
198+
#### `tabBarIconStyle`
186199

187-
##### `inactiveBackgroundColor`
200+
Style object for the tab icon.
188201

189-
Background color of the inactive tab item.
202+
#### `tabBarBadge`
190203

191-
##### `tabStyle`
204+
Text to show in a badge on the tab icon. Accepts a `string` or a `number`.
192205

193-
Style object for the tab item.
206+
#### `tabBarBadgeStyle`
194207

195-
##### `showLabel`
208+
Style for the badge on the tab icon. You can specify a background color or text color here.
196209

197-
Whether to show label for tab, default is `true`.
210+
#### `tabBarAccessibilityLabel`
198211

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.
200213

201-
Style object for the tab label text.
214+
#### `tabBarTestID`
202215

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.
204221

205-
Whether the label is rendered below the icon or beside the icon. Possible values are:
222+
You can specify a custom implementation here:
206223

207-
- `below-icon`
208-
- `beside-icon`
224+
```js
225+
tabBarButton: props => <TouchableOpacity {...props} />
226+
```
209227

210-
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`
211229

212-
##### `adaptive`
230+
Color for the icon and label in the active tab.
213231

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`
215233

216-
##### `allowFontScaling`
234+
Color for the icon and label in the inactive tabs.
217235

218-
Whether label font should scale to respect Text Size accessibility settings, default is true.
236+
#### `tabBarActiveBackgroundColor`
219237

220-
##### `keyboardHidesTabBar`
238+
Background color for the active tab.
221239

222-
Whether the tab bar is hidden when the keyboard opens. Defaults to `false`.
240+
#### `tabBarInactiveBackgroundColor`
223241

224-
##### `safeAreaInsets`
242+
Background color for the inactive tabs.
225243

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`
227245

228-
Takes an object containing following optional properties:
246+
Whether the tab bar is hidden when the keyboard opens. Defaults to `false`.
229247

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`
234249

235-
##### `style`
250+
Style object for the tab item container.
251+
252+
##### `tabBarStyle`
236253

237254
Style object for the tab bar. You can configure styles such as background color here.
238255

239256
To show your screen under the tab bar, you can set the `position` style to absolute:
240257

241258
```js
242-
style: {
243-
position: 'absolute';
244-
}
259+
<Tab.Navigator
260+
screenOptions={{
261+
tabBarStyle: { position: 'absolute' },
262+
}}
263+
>
245264
```
246265

247266
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';
270289
const tabBarHeight = useBottomTabBarHeight();
271290
```
272291

273-
### Options
292+
#### `tabBarBackground`
274293

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.:
276295

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';
298298

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.
299+
// ...
300300

301-
#### `tabBarAccessibilityLabel`
301+
<Tab.Navigator
302+
screenOptions={{
303+
tabBarStyle: { position: 'absolute' },
304+
tabBarBackground: () => (
305+
<BlurView tint="light" intensity={100} style={StyleSheet.absoluteFill} />
306+
),
307+
}}
308+
>
309+
```
302310

303-
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.
304312

305-
#### `tabBarTestID`
313+
#### `lazy`
306314

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.
308316

309317
#### `unmountOnBlur`
310318

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,14 +293,15 @@ The list of the options and their new name are follows:
293293
- `activeBackgroundColor` -> `tabBarActiveBackgroundColor`
294294
- `inactiveBackgroundColor` -> `tabBarInactiveBackgroundColor`
295295
- `allowFontScaling` -> `tabBarAllowFontScaling`
296-
- `adaptive` -> `tabBarAdaptive`
297296
- `showLabel` -> `tabBarShowLabel`
298297
- `labelPosition` -> `tabBarLabelPosition`
299298
- `labelStyle` -> `tabBarLabelStyle`
300299
- `iconStyle` -> `tabBarIconStyle`
301300
- `tabStyle` -> `tabBarItemStyle`
302301
- `style` -> `tabBarStyle`
303302

303+
The `adaptive` option is removed since you can already disable the automatic label positioning by specifying a `tabBarLabelPosition`.
304+
304305
To keep the same behavior as before, you can specify these in `screenOptions`.
305306

306307
### The `tabBarVisible` option is no longer present

0 commit comments

Comments
 (0)