Skip to content

Commit fc72e2c

Browse files
committed
Align icon related docs
1 parent e36c05d commit fc72e2c

8 files changed

Lines changed: 71 additions & 95 deletions

File tree

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ function MyTabBar({ navigation }) {
300300
}
301301
```
302302

303-
Also see [icons documentation](icons.md) to use system icons such as [`SF Symbols`](https://developer.apple.com/sf-symbols/) and [Material Design Icons](https://material.io/resources/icons/) in your custom tab bar.
303+
Also see [Icons](icons.md) for supported icon formats such as [SF Symbols](https://developer.apple.com/sf-symbols/), [Material Symbols](https://fonts.google.com/icons), and [images](icons.md#images) in your custom tab bar.
304304

305305
### Options
306306

@@ -575,14 +575,7 @@ The icon object can be one of the following types:
575575

576576
It's necessary to provide icons for multiple screen densities (1x, 2x, 3x), e.g.: `icon.png`, `icon@2x.png`, `icon@3x.png` etc. as icons are not scaled automatically on iOS for the `native` implementation.
577577

578-
It also supports [drawable resource](https://developer.android.com/guide/topics/resources/drawable-resource) on Android, [xcasset](https://developer.apple.com/documentation/xcode/adding-images-to-your-xcode-project) on iOS:
579-
580-
```js
581-
tabBarIcon: {
582-
type: 'image',
583-
source: { uri: 'icon_name' },
584-
}
585-
```
578+
See [Icons](icons.md#images) for more details.
586579

587580
A `tinted` property can be used to control whether the icon should be tinted with the active/inactive color:
588581

versioned_docs/version-8.x/customizing-bottom-tabs.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ This is similar to how you would customize a stack navigator — there are s
1212

1313
Icons can be specified using the [`tabBarIcon`](bottom-tab-navigator.md#tabbaricon) option. The format of the icon varies based on the platform:
1414

15-
- Local image - all platforms
16-
- SF Symbols name - iOS
17-
- Custom drawable name - Android
15+
- [Images](icons.md#images) - all platforms
16+
- [SF Symbols](icons.md#sf-symbols) name - iOS
17+
- [Material Symbols](icons.md#material-symbols) name - Android
1818

1919
```js name="Tab bar icons" static2dynamic
2020
import * as React from 'react';
@@ -105,15 +105,13 @@ Let's dissect this:
105105

106106
- [`tabBarIcon`](bottom-tab-navigator.md#tabbaricon) is a supported option in bottom tab navigator. So we know we can use it on our screen components in the `options` prop.
107107
- `tabBarIcon` is an object specifying the icon to display.
108-
- For iOS, you can use SF Symbols by setting `type: 'sfSymbol'` and providing the symbol `name`.
109-
- For Android, you can use Material Symbols by setting `type: 'materialSymbol'` and providing the symbol `name`.
110-
- For other platforms, use `type: 'image'` with a `source` pointing to your image file. Image files must be provided for multiple screen densities (1x, 2x, 3x), e.g.: `home-icon.png`, `home-icon@2x.png`, `home-icon@3x.png`.
108+
- For iOS, you can use [SF Symbols](icons.md#sf-symbols) by setting `type: 'sfSymbol'` and providing the symbol `name`.
109+
- For Android, you can use [Material Symbols](icons.md#material-symbols) by setting `type: 'materialSymbol'` and providing the symbol `name`.
110+
- For other platforms, use [`type: 'image'`](icons.md#images) with a `source` pointing to your image file. Image files must be provided for multiple screen densities (1x, 2x, 3x), e.g.: `home-icon.png`, `home-icon@2x.png`, `home-icon@3x.png`.
111111
- [`Platform.select`](https://reactnative.dev/docs/platform#select) can be used to provide different icons based on the platform.
112112
- 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.
113113
- Read the [full API reference](bottom-tab-navigator.md) for further information on `createBottomTabNavigator` configuration options.
114114

115-
See [Icons](icons.md) for more details on different icon types and how to use them with React Navigation.
116-
117115
### Different icons for active and inactive states
118116

119117
You can also provide different icons for active and inactive states by using a function for the `tabBarIcon` option:

versioned_docs/version-8.x/drawer-navigator.md

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -320,67 +320,60 @@ String or a function that given `{ focused: boolean, color: string }` returns a
320320

321321
#### `drawerIcon`
322322

323-
Icon object to display or a function that given `{ focused: boolean, color: string, size: number }` returns an icon to display in drawer sidebar.
323+
Icon object to display or a function that given `{ focused: boolean, color: string, size: number }` returns an icon to display in the drawer.
324324

325-
It supports the following types:
325+
The icon object can be one of the following types:
326326

327-
- `materialSymbol` (Android only)
327+
- Local image - Supported on all platforms
328328

329329
```js
330330
drawerIcon: {
331-
type: 'materialSymbol',
332-
name: 'favorite',
333-
}
334-
```
335-
336-
It also supports the following optional properties:
337-
- `variant` - Supported values: `outlined`, `rounded`, `sharp`
338-
- `weight` - Supported values: `100`, `200`, `300`, `400`, `500`, `600`, `700`
339-
340-
See [Icons](icons.md#material-symbols) for more details.
341-
342-
- `sfSymbol` (iOS only)
343-
344-
```js
345-
drawerIcon: {
346-
type: 'sfSymbol',
347-
name: 'heart',
331+
type: 'image',
332+
source: require('./path/to/icon.png'),
348333
}
349334
```
350335

351-
See [Icons](icons.md#sf-symbols) for more details.
336+
See [Icons](icons.md#images) for more details.
352337

353-
- `image`
338+
A `tinted` property can be used to control whether the icon should be tinted with the active/inactive color:
354339

355340
```js
356341
drawerIcon: {
357342
type: 'image',
358343
source: require('./path/to/icon.png'),
344+
tinted: false,
359345
}
360346
```
361347

362-
It also supports [drawable resource](https://developer.android.com/guide/topics/resources/drawable-resource) on Android, [xcasset](https://developer.apple.com/documentation/xcode/adding-images-to-your-xcode-project) on iOS:
348+
Set `tinted` to `false` if the image has its own colors that you want to preserve.
349+
350+
The image is tinted by default.
351+
352+
- [SF Symbols](https://developer.apple.com/sf-symbols/) name - Supported on iOS
363353

364354
```js
365355
drawerIcon: {
366-
type: 'image',
367-
source: { uri: 'icon_name' },
356+
type: 'sfSymbol',
357+
name: 'heart',
368358
}
369359
```
370360

371-
A `tinted` property can be used to control whether the icon should be tinted with the active/inactive color:
361+
See [Icons](icons.md#sf-symbols) for more details.
362+
363+
- [Material Symbols](https://fonts.google.com/icons) name - Supported on Android
372364

373365
```js
374366
drawerIcon: {
375-
type: 'image',
376-
source: require('./path/to/icon.png'),
377-
tinted: false,
367+
type: 'materialSymbol',
368+
name: 'favorite',
378369
}
379370
```
380371

381-
Set `tinted` to `false` if the image has its own colors that you want to preserve.
372+
It also supports the following optional properties:
373+
- `variant` - Supported values: `outlined`, `rounded`, `sharp`
374+
- `weight` - Supported values: `100`, `200`, `300`, `400`, `500`, `600`, `700`
382375

383-
The image is tinted by default.
376+
See [Icons](icons.md#material-symbols) for more details.
384377

385378
In addition to the icon object, you can also provide a function which returns an icon object or a React element. It receives `focused`, `color`, and `size` in its argument object:
386379

@@ -697,7 +690,7 @@ header: ({ navigation, route, options }) => {
697690
};
698691
```
699692

700-
Also see [icons documentation](icons.md) to use system icons such as [`SF Symbols`](https://developer.apple.com/sf-symbols/) and [Material Design Icons](https://material.io/resources/icons/) in your custom header.
693+
Also see [Icons](icons.md) for supported icon formats such as [SF Symbols](https://developer.apple.com/sf-symbols/), [Material Symbols](https://fonts.google.com/icons), and [images](icons.md#images) in your custom header.
701694

702695
To set a custom header for all the screens in the navigator, you can specify this option in the `screenOptions` prop of the navigator.
703696

@@ -748,7 +741,7 @@ headerLeft: (props) => (
748741
);
749742
```
750743

751-
See [Icons](icons.md) documentation on how to use [SF Symbols](icons.md#sf-symbols) and [Material Symbols](icons.md#material-symbols).
744+
See [Icons](icons.md) documentation on how to use [SF Symbols](icons.md#sf-symbols), [Material Symbols](icons.md#material-symbols), and [images](icons.md#images).
752745

753746
### Events
754747

versioned_docs/version-8.x/elements.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ Usage:
671671

672672
#### Custom back icon
673673

674-
The `icon` prop accepts an icon object for SF Symbols on iOS, Material Symbols on Android and image source on all platforms:
674+
The `icon` prop accepts an icon object for [SF Symbols](icons.md#sf-symbols) on iOS, [Material Symbols](icons.md#material-symbols) on Android, and [image sources](icons.md#images) on all platforms:
675675

676676
```js
677677
<HeaderBackButton

versioned_docs/version-8.x/icons.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,9 +441,7 @@ The component accepts the following props:
441441

442442
The available weights depend on which weights are included in the bundle. If the specified weight is not included, it will throw an error.
443443

444-
## Other sources
445-
446-
### Images
444+
## Images
447445

448446
React Navigation also supports using images as icons. It supports the same formats as React Native's [`Image`](https://reactnative.dev/docs/image) component.
449447

@@ -473,6 +471,8 @@ tabBarIcon: {
473471

474472
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`.
475473

474+
## Other sources
475+
476476
### [React Native Vector Icons](https://github.com/oblador/react-native-vector-icons)
477477

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

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

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ function MyTabBar({ navigation }) {
340340
}
341341
```
342342

343-
Also see [icons documentation](icons.md) to use system icons such as [`SF Symbols`](https://developer.apple.com/sf-symbols/) and [Material Design Icons](https://material.io/resources/icons/) in your custom tab bar.
343+
Also see [Icons](icons.md) for supported icon formats such as [SF Symbols](https://developer.apple.com/sf-symbols/), [Material Symbols](https://fonts.google.com/icons), and [images](icons.md#images) in your custom tab bar.
344344

345345
### Options
346346

@@ -441,65 +441,58 @@ Whether the tab label should be visible. Defaults to `true`.
441441

442442
Icon object to display or a function that given `{ focused: boolean, color: string, size: number }` returns an icon to display in the tab bar.
443443

444-
It supports the following types:
444+
The icon object can be one of the following types:
445445

446-
- `materialSymbol` (Android only)
446+
- Local image - Supported on all platforms
447447

448448
```js
449449
tabBarIcon: {
450-
type: 'materialSymbol',
451-
name: 'favorite',
452-
}
453-
```
454-
455-
It also supports the following optional properties:
456-
- `variant` - Supported values: `outlined`, `rounded`, `sharp`
457-
- `weight` - Supported values: `100`, `200`, `300`, `400`, `500`, `600`, `700`
458-
459-
See [Icons](icons.md#material-symbols) for more details.
460-
461-
- `sfSymbol` (iOS only)
462-
463-
```js
464-
tabBarIcon: {
465-
type: 'sfSymbol',
466-
name: 'heart',
450+
type: 'image',
451+
source: require('./path/to/icon.png'),
467452
}
468453
```
469454

470-
See [Icons](icons.md#sf-symbols) for more details.
455+
See [Icons](icons.md#images) for more details.
471456

472-
- `image`
457+
A `tinted` property can be used to control whether the icon should be tinted with the active/inactive color:
473458

474459
```js
475460
tabBarIcon: {
476461
type: 'image',
477462
source: require('./path/to/icon.png'),
463+
tinted: false,
478464
}
479465
```
480466

481-
It also supports [drawable resource](https://developer.android.com/guide/topics/resources/drawable-resource) on Android, [xcasset](https://developer.apple.com/documentation/xcode/adding-images-to-your-xcode-project) on iOS:
467+
Set `tinted` to `false` if the image has its own colors that you want to preserve.
468+
469+
The image is tinted by default.
470+
471+
- [SF Symbols](https://developer.apple.com/sf-symbols/) name - Supported on iOS
482472

483473
```js
484474
tabBarIcon: {
485-
type: 'image',
486-
source: { uri: 'icon_name' },
475+
type: 'sfSymbol',
476+
name: 'heart',
487477
}
488478
```
489479

490-
A `tinted` property can be used to control whether the icon should be tinted with the active/inactive color:
480+
See [Icons](icons.md#sf-symbols) for more details.
481+
482+
- [Material Symbols](https://fonts.google.com/icons) name - Supported on Android
491483

492484
```js
493485
tabBarIcon: {
494-
type: 'image',
495-
source: require('./path/to/icon.png'),
496-
tinted: false,
486+
type: 'materialSymbol',
487+
name: 'favorite',
497488
}
498489
```
499490

500-
Set `tinted` to `false` if the image has its own colors that you want to preserve.
491+
It also supports the following optional properties:
492+
- `variant` - Supported values: `outlined`, `rounded`, `sharp`
493+
- `weight` - Supported values: `100`, `200`, `300`, `400`, `500`, `600`, `700`
501494

502-
The image is tinted by default.
495+
See [Icons](icons.md#material-symbols) for more details.
503496

504497
In addition to the icon object, you can also provide a function which returns an icon object or a React element. It receives `focused`, `color`, and `size` in its argument object:
505498

versioned_docs/version-8.x/native-stack-navigator.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,8 @@ It supports the following types:
635635
}
636636
```
637637

638+
See [Icons](icons.md#images) for more details.
639+
638640
Defaults to back icon image for the platform:
639641

640642
- A chevron on iOS
@@ -1222,7 +1224,7 @@ header: ({ navigation, route, options, back }) => {
12221224
12231225
To set a custom header for all the screens in the navigator, you can specify this option in the `screenOptions` prop of the navigator.
12241226
1225-
Also see [icons documentation](icons.md) to use system icons such as [`SF Symbols`](https://developer.apple.com/sf-symbols/) and [Material Design Icons](https://material.io/resources/icons/) in your custom header.
1227+
Also see [Icons](icons.md) for supported icon formats such as [SF Symbols](https://developer.apple.com/sf-symbols/), [Material Symbols](https://fonts.google.com/icons), and [images](icons.md#images) in your custom header.
12261228
12271229
Note that if you specify a custom header, the native functionality such as large title, search bar etc. won't work.
12281230
@@ -1711,14 +1713,7 @@ Common properties:
17111713
17121714
It's necessary to provide icons for multiple screen densities (1x, 2x, 3x), e.g.: `icon.png`, `icon@2x.png`, `icon@3x.png` etc. as icons are not scaled automatically.
17131715
1714-
It also supports [xcasset](https://developer.apple.com/documentation/xcode/adding-images-to-your-xcode-project):
1715-
1716-
```js
1717-
icon: {
1718-
type: 'image',
1719-
source: { uri: 'icon_name' },
1720-
}
1721-
```
1716+
See [Icons](icons.md#images) for more details.
17221717
17231718
A `tinted` property can be used to control whether the icon should be tinted with the active/inactive color:
17241719
@@ -1741,6 +1736,8 @@ Common properties:
17411736
}
17421737
```
17431738
1739+
See [Icons](icons.md#sf-symbols) for more details.
1740+
17441741
- `variant`: Visual variant of the button. Supported values:
17451742
- `plain` (default)
17461743
- `done`

versioned_docs/version-8.x/stack-navigator.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ header: ({ navigation, route, options, back }) => {
294294

295295
To set a custom header for all the screens in the navigator, you can specify this option in the `screenOptions` prop of the navigator.
296296

297-
Also see [icons documentation](icons.md) to use system icons such as [`SF Symbols`](https://developer.apple.com/sf-symbols/) and [Material Design Icons](https://material.io/resources/icons/) in your custom header.
297+
Also see [Icons](icons.md) for supported icon formats such as [SF Symbols](https://developer.apple.com/sf-symbols/), [Material Symbols](https://fonts.google.com/icons), and [images](icons.md#images) in your custom header.
298298

299299
When using a custom header, there are 2 things to keep in mind:
300300

@@ -387,6 +387,8 @@ It supports the following types:
387387
}
388388
```
389389

390+
See [Icons](icons.md#images) for more details.
391+
390392
In addition to the icon object, you can also provide a function which returns a React Element to display as the back icon. It receives `tintColor` in its argument object:
391393

392394
```js

0 commit comments

Comments
 (0)