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-8.x/customizing-bottom-tabs.md
+2-17Lines changed: 2 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -112,6 +112,8 @@ Let's dissect this:
112
112
- The `tabBarActiveTintColor` and `tabBarInactiveTintColor` options in `screenOptions` control the icon and label colors. These default to the iOS platform defaults, but you can change them as shown above.
113
113
- Read the [full API reference](bottom-tab-navigator.md) for further information on `createBottomTabNavigator` configuration options.
114
114
115
+
See [Icons](icons.md) for more details on different icon types and how to use them with React Navigation.
116
+
115
117
### Different icons for active and inactive states
116
118
117
119
You can also provide different icons for active and inactive states by using a function for the `tabBarIcon` option:
@@ -131,23 +133,6 @@ The `focused` parameter indicates whether the tab is active or inactive.
131
133
132
134
This not supported on Android with `native`[implementation](bottom-tab-navigator.md#implementation), the icon specified for inactive state will be used for both active and inactive states.
133
135
134
-
### Using [React Native Vector Icons](https://github.com/oblador/react-native-vector-icons)
135
-
136
-
The React Native Vector Icons library provides a large set of icons. To use vector icons in your tab bar, we'd need to [get an image source](https://github.com/oblador/react-native-vector-icons?tab=readme-ov-file#usage-as-png-imagesource-object) from the icon component.
137
-
138
-
First, make sure to install the appropriate icon package (e.g. `@react-native-vector-icons/lucide`) and `@react-native-vector-icons/get-image` and rebuild the app after installation. Then, you can use the `getImageSourceSync` method to get the image source for the desired icon:
Copy file name to clipboardExpand all lines: versioned_docs/version-8.x/icons.md
+51Lines changed: 51 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -440,3 +440,54 @@ The component accepts the following props:
440
440
-`"bold"` (`700`)
441
441
442
442
The available weights depend on which weights are included in the bundle. If the specified weight is not included, it will throw an error.
443
+
444
+
## Other sources
445
+
446
+
### Images
447
+
448
+
React Navigation also supports using images as icons. It supports the same formats as React Native's [`Image`](https://reactnative.dev/docs/image) component.
449
+
450
+
You can use the `type: 'image'` option with a `source` property pointing to your image file:
451
+
452
+
```js
453
+
tabBarIcon: {
454
+
type:'image',
455
+
source:require('./path/to/icon.png'),
456
+
}
457
+
```
458
+
459
+
:::note
460
+
461
+
It's necessary to provide icons for multiple screen densities (1x, 2x, 3x), e.g.: `icon.png`, `icon@2x.png`, `icon@3x.png`, as icons are not scaled automatically on iOS.
462
+
463
+
:::
464
+
465
+
Images also include [drawable resources](https://developer.android.com/guide/topics/resources/drawable-resource) on Android and [asset catalogs](https://developer.apple.com/documentation/xcode/adding-images-to-your-xcode-project) on iOS, which can be specified using `uri`:
466
+
467
+
```js
468
+
tabBarIcon: {
469
+
type:'image',
470
+
source: { uri:'icon_name' },
471
+
}
472
+
```
473
+
474
+
Here `icon_name` is the resource name without the file extension. On Android, this can refer to a bitmap drawable such as `res/drawable/icon_name.png` or a vector drawable such as `res/drawable/icon_name.xml`. On iOS, this can refer to an image in an asset catalog, such as an image set named `icon_name`.
The React Native Vector Icons library provides a large set of icons. However, these icons are rendered using custom fonts, which are not supported in most native navigation components such as tab bars or headers.
479
+
480
+
As an alternative, you can [rasterize the icon into an image source](https://github.com/oblador/react-native-vector-icons?tab=readme-ov-file#usage-as-png-imagesource-object). This image can then be used as an icon in such components using the `type: 'image'` option.
481
+
482
+
First, install the appropriate icon package, such as `@react-native-vector-icons/lucide`, along with `@react-native-vector-icons/get-image`. Then rebuild the app and use `getImageSourceSync` to create the image source:
0 commit comments