Skip to content

Commit 719da95

Browse files
committed
Update material top tab docs
1 parent 54b9f4f commit 719da95

File tree

1 file changed

+107
-53
lines changed

1 file changed

+107
-53
lines changed

versioned_docs/version-6.x/material-top-tab-navigator.md

Lines changed: 107 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -71,24 +71,6 @@ It supports the following values:
7171

7272
Position of the tab bar in the tab view. Possible values are `'top'` and `'bottom'`. Defaults to `'top'`.
7373

74-
#### `lazy`
75-
76-
Boolean indicating whether to lazily render the scenes. When this is set to `true`, screens will be rendered as they come into the viewport. By default all scenes are rendered to provide a smoother swipe experience. But you might want to defer the rendering of screens out of the viewport until the user sees them. To enable lazy rendering, set `lazy` to `true`.
77-
78-
When you enable `lazy`, the lazy loaded screens will usually take some time to render when they come into the viewport. You can use the `lazyPlaceholder` prop to customize what the user sees during this short period.
79-
80-
#### `lazyPreloadDistance`
81-
82-
When `lazy` is enabled, you can specify how many adjacent routes should be preloaded in advance with this prop. This value defaults to `0` which means lazy pages are loaded as they come into the viewport.
83-
84-
#### `lazyPlaceholder`
85-
86-
Function that returns a React element to render for routes that haven't been rendered yet. Receives an object containing the route as the argument. The `lazy` prop also needs to be enabled.
87-
88-
This view is usually only shown for a split second. Keep it lightweight.
89-
90-
By default, this renders `null`.
91-
9274
#### `keyboardDismissMode`
9375

9476
String indicating whether the keyboard gets dismissed in response to a drag gesture. Possible values are:
@@ -97,11 +79,6 @@ String indicating whether the keyboard gets dismissed in response to a drag gest
9779
- `'on-drag'`: the keyboard is dismissed when a drag begins.
9880
- `'none'`: drags do not dismiss the keyboard.
9981

100-
#### `swipeEnabled`
101-
102-
Boolean indicating whether to enable swipe gestures. Swipe gestures are enabled by default. Passing `false` will disable swipe gestures, but the user can still switch tabs by pressing the tab bar.
103-
104-
10582
#### `initialLayout`
10683

10784
Object containing the initial height and width of the screens. Passing this will improve the initial rendering performance. For most apps, this is a good default:
@@ -213,65 +190,142 @@ function MyTabBar({ navigation }) {
213190
}
214191
```
215192

216-
#### `tabBarOptions`
217-
218-
An object containing the props for the tab bar component. It can contain the following properties:
219-
220-
- `activeTintColor` - Label and icon color of the active tab.
221-
- `inactiveTintColor` - Label and icon color of the inactive tab.
222-
- `showIcon` - Whether to show icon for tab, default is false.
223-
- `showLabel` - Whether to show label for tab, default is true.
224-
- `pressColor` - Color for material ripple (Android >= 5.0 only).
225-
- `pressOpacity` - Opacity for pressed tab (iOS and Android < 5.0 only).
226-
- `scrollEnabled` - Whether to enable scrollable tabs.
227-
- `tabStyle` - Style object for the tab.
228-
- `indicatorStyle` - Style object for the tab indicator (line at the bottom of the tab).
229-
- `labelStyle` - Style object for the tab label. Specifying a color here will override the color specified in `activeTintColor` and `inactiveTintColor` for the label.
230-
- `iconStyle` - Style object for the tab icon.
231-
- `style` - Style object for the tab bar.
232-
- `allowFontScaling` - Whether label font should scale to respect Text Size accessibility settings, default is true.
233-
- `renderIndicator` - Function which takes an object with the current route and returns a custom React Element to be used as a tab indicator.
193+
### Options
194+
195+
The following [options](screen-options.md) can be used to configure the screens in the navigator:
234196

235197
Example:
236198

237199
<samp id="material-top-tab-options" />
238200

239201
```js
240202
<Tab.Navigator
241-
tabBarOptions={{
242-
labelStyle: { fontSize: 12 },
243-
tabStyle: { width: 100 },
244-
style: { backgroundColor: 'powderblue' },
203+
screenOptions={{
204+
tabBarLabelStyle: { fontSize: 12 },
205+
tabBarItemStyle: { width: 100 },
206+
tabBarStyle: { backgroundColor: 'powderblue' },
245207
}}
246208
>
247209
{/* ... */}
248210
</Tab.Navigator>
249211
```
250212

251-
### Options
252-
253-
The following [options](screen-options.md) can be used to configure the screens in the navigator:
254-
255213
#### `title`
256214

257215
Generic title that can be used as a fallback for `headerTitle` and `tabBarLabel`.
258216

217+
#### `tabBarLabel`
218+
219+
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`](#tabbarshowlabel) option.
220+
221+
#### `tabBarAccessibilityLabel`
222+
223+
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.
224+
225+
#### `tabBarAllowFontScaling`
226+
227+
Whether label font should scale to respect Text Size accessibility settings.
228+
229+
#### `tabBarShowLabel`
230+
231+
Whether the tab label should be visible. Defaults to `true`.
232+
259233
#### `tabBarIcon`
260234

261235
Function that given `{ focused: boolean, color: string }` returns a React.Node, to display in the tab bar.
262236

263-
#### `tabBarLabel`
237+
#### `tabBarShowIcon`
264238

265-
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.
239+
Whether the tab icon should be visible. Defaults to `false`.
266240

267-
#### `tabBarAccessibilityLabel`
241+
#### `tabBarBadge`
268242

269-
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.
243+
Function that returns a React element to use as a badge for the tab.
244+
245+
#### `tabBarIndicator`
246+
247+
Function that returns a React element as the tab bar indicator.
248+
249+
#### `tabBarIndicatorStyle`
250+
251+
Style object for the tab bar indicator.
252+
253+
#### `tabBarIndicatorContainerStyle`
254+
255+
Style object for the view containing the tab bar indicator.
270256

271257
#### `tabBarTestID`
272258

273259
ID to locate this tab button in tests.
274260

261+
#### `tabBarActiveTintColor`
262+
263+
Color for the icon and label in the active tab.
264+
265+
#### `tabBarInactiveTintColor`
266+
267+
Color for the icon and label in the inactive tabs.
268+
269+
#### `tabBarPressColor`
270+
271+
Color for material ripple (Android >= 5.0 only).
272+
273+
#### `tabBarPressOpacity`
274+
275+
Opacity for pressed tab (iOS and Android < 5.0 only).
276+
277+
#### `tabBarBounces`
278+
279+
Boolean indicating whether the tab bar bounces when overscrolling.
280+
281+
#### `tabBarScrollEnabled`
282+
283+
Boolean indicating whether to make the tab bar scrollable.
284+
285+
If you set this to `true`, you should also specify a width in `tabBarItemStyle` to improve the performance of initial render.
286+
287+
#### `tabBarIconStyle`
288+
289+
Style object for the tab icon container.
290+
291+
#### `tabBarLabelStyle`
292+
293+
Style object for the tab label.
294+
295+
#### `tabBarItemStyle`
296+
297+
Style object for the individual tab items.
298+
299+
#### `tabBarContentContainerStyle`
300+
301+
Style object for the view containing the tab items.
302+
303+
#### `tabBarStyle`
304+
305+
Style object for the the tab bar.
306+
307+
#### `swipeEnabled`
308+
309+
Boolean indicating whether to enable swipe gestures. Swipe gestures are enabled by default. Passing `false` will disable swipe gestures, but the user can still switch tabs by pressing the tab bar.
310+
311+
#### `lazy`
312+
313+
Whether this screen should be lazily rendered. When this is set to `true`, the screen will be rendered as it comes into the viewport. By default all screens are rendered to provide a smoother swipe experience. But you might want to defer the rendering of screens out of the viewport until the user sees them. To enable lazy rendering for this screen, set `lazy` to `true`.
314+
315+
When you enable `lazy`, the lazy loaded screens will usually take some time to render when they come into the viewport. You can use the `lazyPlaceholder` prop to customize what the user sees during this short period.
316+
317+
#### `lazyPreloadDistance`
318+
319+
When `lazy` is enabled, you can specify how many adjacent screens should be preloaded in advance with this prop. This value defaults to `0` which means lazy pages are loaded as they come into the viewport.
320+
321+
#### `lazyPlaceholder`
322+
323+
Function that returns a React element to render if this screen hasn't been rendered yet. The `lazy` option also needs to be enabled for this to work.
324+
325+
This view is usually only shown for a split second. Keep it lightweight.
326+
327+
By default, this renders `null`.
328+
275329
### Events
276330

277331
The navigator can [emit events](navigation-events.md) on certain actions. Supported events are:

0 commit comments

Comments
 (0)