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-7.x/tab-view.md
+75-48
Original file line number
Diff line number
Diff line change
@@ -250,7 +250,7 @@ Position of the tab bar in the tab view. Possible values are `'top'` and `'botto
250
250
251
251
Function which takes an object with the current route and returns a boolean to indicate whether to lazily render the scenes.
252
252
253
-
By default all scenes are rendered to provide a smoother swipe experience. But you might want to defer the rendering of unfocused scenes until the user sees them. To enable lazy rendering for a particular scene, return `true` from `getLazy` for that `route`:
253
+
By default all scenes are rendered to provide a smoother swipe experience. But you might want to defer the rendering of unfocused scenes until the user sees them. To enable lazy rendering for a particular scene, return `true` from `lazy` for that `route`:
254
254
255
255
```js
256
256
<TabView
@@ -358,72 +358,103 @@ return (
358
358
359
359
#### TabBar Props
360
360
361
-
##### `getLabelText`
361
+
##### Options
362
362
363
-
Function which takes an object with the current route and returns the label text for the tab. Uses `route.title` by default.
363
+
Options describe how each tab should be rendered. There are 2 ways to specify options:
364
+
365
+
-`commonOptions`: Options that apply to all tabs.
366
+
-`options`: Options that apply to specific tabs. It has the route key as the key and the object with options.
367
+
368
+
Example:
364
369
365
370
```js
366
371
<TabBar
367
-
getLabelText={({ route }) =>route.title}
368
-
...
372
+
commonOptions={{
373
+
icon: ({ route, focused, color }) => (
374
+
<Icon name={route.icon} color={color} />
375
+
),
376
+
}}
377
+
options={{
378
+
albums: {
379
+
labelText:'Albums',
380
+
},
381
+
profile: {
382
+
labelText:'Profile',
383
+
},
384
+
}}
369
385
/>
370
386
```
371
387
372
-
##### `getAccessible`
388
+
The following options are available:
373
389
374
-
Function which takes an object with the current route and returns a boolean to indicate whether to mark a tab as `accessible`. Defaults to `true`.
390
+
###### `accessibilityLabel`
375
391
376
-
##### `getAccessibilityLabel`
392
+
Accessibility label for the tab button. Uses `route.accessibilityLabel` by default if specified, otherwise uses the route title.
377
393
378
-
Function which takes an object with the current route and returns a accessibility label for the tab button. Uses `route.accessibilityLabel` by default if specified, otherwise uses the route title.
Whether to mark the tab as `accessible`. Defaults to `true`.
397
+
398
+
###### `testID`
399
+
400
+
Test ID for the tab button. Uses `route.testID` by default.
401
+
402
+
###### `labelText`
403
+
404
+
Label text for the tab button. Uses `route.title` by default.
405
+
406
+
###### `labelAllowFontScaling`
407
+
408
+
Whether label font should scale to respect Text Size accessibility settings. Defaults to `true`.
409
+
410
+
###### `href`
411
+
412
+
URL to use for the anchor tag for the tab button on the Web.
386
413
387
-
#####`getTestID`
414
+
###### `label`
388
415
389
-
Function which takes an object with the current route and returns a test id for the tab button to locate this tab button in tests. Uses `route.testID` by default.
416
+
A function that returns a custom React Element to be used as a label. The function receives an object with the following properties:
417
+
418
+
-`route` - The route object for the tab.
419
+
-`labelText` - The label text for the tab specified in the `labelText` option or the `route title`.
420
+
-`focused` - Whether the label is for the focused state.
421
+
-`color` - The color of the label.
422
+
-`allowFontScaling` - Whether label font should scale to respect Text Size accessibility settings.
423
+
-`style` - The style object for the label.
390
424
391
425
```js
392
-
<TabBar
393
-
getTestID={({ route }) =>route.testID}
394
-
...
395
-
/>
426
+
label: ({ route, labelText, focused, color }) => (
0 commit comments