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/native-stack-navigator.md
+6-20Lines changed: 6 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1617,7 +1617,7 @@ If the content's height is less than the sheet's height, the remaining area may
1617
1617
1618
1618
## Header items
1619
1619
1620
-
The [`unstable_headerLeftItems`](#unstable_headerleftitems) and [`unstable_headerRightItems`](#unstable_headerrightitems) options allow you to add header items to the left and right side of the header respectively. This items can show native buttons, menus or custom React elements.
1620
+
The [`unstable_headerLeftItems`](#unstable_headerleftitems) and [`unstable_headerRightItems`](#unstable_headerrightitems) options allow you to add header items to the left and right side of the header respectively. These items can show native buttons, menus or custom React elements.
1621
1621
1622
1622
On iOS 26+, the header right items can also be collapsed into an overflow menu by the system when there is not enough space to show all items. Note that custom elements (with `type:'custom'`) won't be collapsed into the overflow menu.
1623
1623
@@ -1642,7 +1642,7 @@ Common properties:
1642
1642
- `color` (of type `ColorValue`)
1643
1643
- `icon`: Optional icon to show instead of the label.
1644
1644
1645
-
The icon can be of following types:
1645
+
The icon can be one of the following types:
1646
1646
- Local image
1647
1647
1648
1648
```js
@@ -1657,7 +1657,7 @@ Common properties:
1657
1657
It also supports [xcasset](https://developer.apple.com/documentation/xcode/adding-images-to-your-xcode-project):
1658
1658
1659
1659
```js
1660
-
tabBarIcon: {
1660
+
icon: {
1661
1661
type:'image',
1662
1662
source: { uri:'icon_name' },
1663
1663
}
@@ -1666,7 +1666,7 @@ Common properties:
1666
1666
A `tinted` property can be used to control whether the icon should be tinted with the active/inactive color:
1667
1667
1668
1668
```js
1669
-
tabBarIcon: {
1669
+
icon: {
1670
1670
type:'image',
1671
1671
source:require('./path/to/icon.png'),
1672
1672
tinted:false,
@@ -1742,14 +1742,7 @@ Supported properties when `type` is `menu`:
1742
1742
- `type`: Must be `action`.
1743
1743
- `label`: Label of the menu item.
1744
1744
- `description`: The secondary text displayed alongside the label of the menu item.
1745
-
- `icon`: Optional icon to show alongside the label. The icon can be a [SF Symbols](https://developer.apple.com/sf-symbols/) name:
1746
-
1747
-
```js
1748
-
{
1749
-
type:'sfSymbol',
1750
-
name:'trash',
1751
-
}
1752
-
```
1745
+
- `icon`: Optional icon to show alongside the label. It accepts the same formats as `icon` above.
1753
1746
1754
1747
- `onPress`: Function to call when the menu item is pressed.
1755
1748
- `state`: Optional state of the menu item. Supported values:
@@ -1765,14 +1758,7 @@ Supported properties when `type` is `menu`:
1765
1758
- `submenu`: An object with the following properties:
1766
1759
- `type`: Must be `submenu`.
1767
1760
- `label`: Label of the submenu item.
1768
-
- `icon`: Optional icon to show alongside the label. The icon can be a [SF Symbols](https://developer.apple.com/sf-symbols/) name:
1769
-
1770
-
```js
1771
-
{
1772
-
type:'sfSymbol',
1773
-
name:'pencil',
1774
-
}
1775
-
```
1761
+
- `icon`: Optional icon to show alongside the label. It accepts the same formats as `icon` above.
1776
1762
1777
1763
- `inline`: Whether the menu is displayed inline with the parent menu. By default, submenus are displayed after expanding the parent menu item. Inline menus are displayed as part of the parent menu as a section. Defaults to `false`.
1778
1764
- `layout`: How the submenu items are displayed. Supported values:
Copy file name to clipboardExpand all lines: versioned_docs/version-8.x/drawer-navigator.md
+83-2Lines changed: 83 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -229,10 +229,12 @@ export default function App() {
229
229
}
230
230
```
231
231
232
+
### `DrawerItem`
233
+
232
234
The `DrawerItem` component accepts the following props:
233
235
234
236
-`label` (required): The label text of the item. Can be string, or a function returning a react element. e.g. `({ focused, color }) => <Text style={{ color }}>{focused ? 'Focused text' : 'Unfocused text'}</Text>`.
235
-
-`icon`: Icon to display for the item. Accepts a function returning a react element. e.g. `({ focused, color, size }) => <Icon color={color} size={size} name={focused ? 'heart' : 'heart-outline'} />`.
237
+
-`icon`: Icon to display for the item. Accepts an icon object, or a function returning an icon object or a React element. See [Icons](icons.md) for supported icon formats.
236
238
-`focused`: Boolean indicating whether to highlight the drawer item as active.
237
239
-`onPress` (required): Function to execute on press.
238
240
-`activeTintColor`: Color for the icon and label when the item is active.
@@ -300,7 +302,86 @@ String or a function that given `{ focused: boolean, color: string }` returns a
300
302
301
303
#### `drawerIcon`
302
304
303
-
Function, that given `{ focused: boolean, color: string, size: number }` returns a React.Node to display in drawer sidebar.
305
+
Icon object to display or a function that given `{ focused: boolean, color: string, size: number }` returns an icon to display in drawer sidebar.
306
+
307
+
It supports the following types:
308
+
309
+
-`materialSymbol` (Android only)
310
+
311
+
```js
312
+
drawerIcon: {
313
+
type:'materialSymbol',
314
+
name:'favorite',
315
+
}
316
+
```
317
+
318
+
It also supports the following optional properties:
See [Icons](icons.md#material-symbols) for more details.
323
+
324
+
-`sfSymbol` (iOS only)
325
+
326
+
```js
327
+
drawerIcon: {
328
+
type:'sfSymbol',
329
+
name:'heart',
330
+
}
331
+
```
332
+
333
+
See [Icons](icons.md#sf-symbols) for more details.
334
+
335
+
-`image`
336
+
337
+
```js
338
+
drawerIcon: {
339
+
type:'image',
340
+
source:require('./path/to/icon.png'),
341
+
}
342
+
```
343
+
344
+
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:
345
+
346
+
```js
347
+
drawerIcon: {
348
+
type:'image',
349
+
source: { uri:'icon_name' },
350
+
}
351
+
```
352
+
353
+
A `tinted` property can be used to control whether the icon should be tinted with the active/inactive color:
354
+
355
+
```js
356
+
drawerIcon: {
357
+
type:'image',
358
+
source:require('./path/to/icon.png'),
359
+
tinted:false,
360
+
}
361
+
```
362
+
363
+
Set `tinted` to `false` if the image has its own colors that you want to preserve.
364
+
365
+
The image is tinted by default.
366
+
367
+
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:
368
+
369
+
```js
370
+
drawerIcon: ({ focused }) => {
371
+
return {
372
+
type:'sfSymbol',
373
+
name: focused ?'heart.fill':'heart',
374
+
};
375
+
},
376
+
```
377
+
378
+
To render a custom React element, you can return it from the function:
Copy file name to clipboardExpand all lines: versioned_docs/version-8.x/icons.md
+7-3Lines changed: 7 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,10 +9,14 @@ Many components in React Navigation accept icons to customize their appearance.
9
9
Here are some common places where icons are used in React Navigation:
10
10
11
11
-[`tabBarIcon`](bottom-tab-navigator.md#tabbaricon) option in Bottom Tab Navigator
12
+
-[`tabBarIcon`](material-top-tab-navigator.md#tabbaricon) option in Material Top Tabs Navigator
13
+
-[`drawerIcon`](drawer-navigator.md#drawericon) option in Drawer Navigator
14
+
-[`icon`](drawer-navigator.md#draweritem) prop in `DrawerItem` component
12
15
-[`headerBackIcon`](native-stack-navigator.md#headerbackicon) option in Native Stack Navigator
13
16
-[`headerBackIcon`](stack-navigator.md#headerbackicon) option in Stack Navigator
14
17
-[`icon`](elements.md#headerbackbutton) prop in `HeaderBackButton` component
15
-
-[`icon`](drawer-navigator.md#headerleft) option in `DrawerToggleButton` component
18
+
-[`icon`](drawer-navigator.md#headerleft) prop in `DrawerToggleButton` component
19
+
-[`icon`](native-stack-navigator.md#header-items) property in Native Stack header items (iOS only, `image` and `sfSymbol` only)
16
20
17
21
Typically, components accept an icon object with a `type` property:
18
22
@@ -49,7 +53,7 @@ The `sfSymbol` and `materialSymbol` types use the respective system icon librari
49
53
50
54
SF Symbols is a library of over 6,900 symbols designed to integrate well with the San Francisco system font on Apple platforms. It comes included with iOS and other Apple platforms.
51
55
52
-
Options such as `tabBarIcon`and `headerBackIcon` accept an object with `type: 'sfSymbol'` and a `name` property to specify the SF Symbol to use:
56
+
Where SF Symbols are supported, icon options and props accept an object with `type: 'sfSymbol'` and a `name` property to specify the SF Symbol to use:
53
57
54
58
```js
55
59
tabBarIcon: {
@@ -205,7 +209,7 @@ You'll need to rebuild your app after changing the font configuration in `packag
205
209
206
210
:::
207
211
208
-
Options such as `tabBarIcon`and `headerBackIcon` accept an object with `type: 'materialSymbol'` and a `name` property to specify the Material Symbol to use:
212
+
Where Material Symbols are supported, icon options and props accept an object with `type: 'materialSymbol'` and a `name` property to specify the Material Symbol to use:
See [Icons](icons.md#material-symbols) for more details.
430
+
431
+
-`sfSymbol` (iOS only)
432
+
433
+
```js
434
+
tabBarIcon: {
435
+
type:'sfSymbol',
436
+
name:'heart',
437
+
}
438
+
```
439
+
440
+
See [Icons](icons.md#sf-symbols) for more details.
441
+
442
+
-`image`
443
+
444
+
```js
445
+
tabBarIcon: {
446
+
type:'image',
447
+
source:require('./path/to/icon.png'),
448
+
}
449
+
```
450
+
451
+
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:
452
+
453
+
```js
454
+
tabBarIcon: {
455
+
type:'image',
456
+
source: { uri:'icon_name' },
457
+
}
458
+
```
459
+
460
+
A `tinted` property can be used to control whether the icon should be tinted with the active/inactive color:
461
+
462
+
```js
463
+
tabBarIcon: {
464
+
type:'image',
465
+
source:require('./path/to/icon.png'),
466
+
tinted:false,
467
+
}
468
+
```
469
+
470
+
Set `tinted` to `false` if the image has its own colors that you want to preserve.
471
+
472
+
The image is tinted by default.
473
+
474
+
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:
475
+
476
+
```js
477
+
tabBarIcon: ({ focused }) => {
478
+
return {
479
+
type:'sfSymbol',
480
+
name: focused ?'heart.fill':'heart',
481
+
};
482
+
},
483
+
```
484
+
485
+
To render a custom React element, you can return it from the function:
0 commit comments