Skip to content

Commit b4d1bc6

Browse files
committed
Document API for icons
1 parent 6b3f225 commit b4d1bc6

File tree

1 file changed

+59
-7
lines changed

1 file changed

+59
-7
lines changed

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

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ Function which returns an array of items to display as on the left side of the h
450450
Example:
451451

452452
```js
453-
unstable_headerLeftItems: () => [
453+
unstable_headerRightItems: () => [
454454
{
455455
type: 'button',
456456
title: 'Edit',
@@ -1527,6 +1527,25 @@ Common properties:
15271527
- `fontWeight`
15281528
- `color`
15291529
- `icon`: Optional icon to show instead of the label.
1530+
1531+
The icon can be an image:
1532+
1533+
```js
1534+
{
1535+
type: 'image',
1536+
source: require('./path/to/image.png'),
1537+
}
1538+
```
1539+
1540+
Or a [SF Symbols](https://developer.apple.com/sf-symbols/) name:
1541+
1542+
```js
1543+
{
1544+
type: 'sfsymbol',
1545+
name: 'heart',
1546+
}
1547+
```
1548+
15301549
- `variant`: Visual variant of the button. Supported values:
15311550
- `plain` (default)
15321551
- `done`
@@ -1555,10 +1574,14 @@ Supported properties when `type` is `button`:
15551574
Example:
15561575

15571576
```js
1558-
unstable_headerLeftItems: () => [
1577+
unstable_headerRightItems: () => [
15591578
{
15601579
type: 'button',
15611580
label: 'Edit',
1581+
icon: {
1582+
type: 'sfsymbol',
1583+
name: 'pencil',
1584+
},
15621585
onPress: () => {
15631586
// Do something
15641587
},
@@ -1570,12 +1593,23 @@ Supported properties when `type` is `menu`:
15701593

15711594
- `changesSelectionAsPrimaryAction`: Whether the menu is a selection menu. Tapping an item in a selection menu will add a checkmark to the selected item. Defaults to `false`.
15721595
- `menu`: An object containing the menu items. It contains the following properties:
1596+
15731597
- `title`: Optional title to show on top of the menu.
15741598
- `items`: An array of menu items. A menu item can be either an `action` or a `submenu`.
1599+
15751600
- `action`: An object with the following properties:
1601+
15761602
- `type`: Must be `action`.
15771603
- `label`: Label of the menu item.
1578-
- `icon`: Optional icon to show alongside the label.
1604+
- `icon`: Optional icon to show alongside the label. The icon can be a [SF Symbols](https://developer.apple.com/sf-symbols/) name:
1605+
1606+
```js
1607+
{
1608+
type: 'sfsymbol',
1609+
name: 'trash',
1610+
}
1611+
```
1612+
15791613
- `onPress`: Function to call when the menu item is pressed.
15801614
- `state`: Optional state of the menu item. Supported values:
15811615
- `on`
@@ -1586,25 +1620,43 @@ Supported properties when `type` is `menu`:
15861620
- `hidden`: Whether the menu item is hidden.
15871621
- `keepsMenuPresented`: Whether to keep the menu open after selecting this item. Defaults to `false`.
15881622
- `discoverabilityLabel`: An elaborated title that explains the purpose of the action.
1623+
15891624
- `submenu`: An object with the following properties:
1625+
15901626
- `type`: Must be `submenu`.
15911627
- `label`: Label of the submenu item.
1592-
- `icon`: Optional icon to show alongside the label.
1628+
- `icon`: Optional icon to show alongside the label. The icon can be a [SF Symbols](https://developer.apple.com/sf-symbols/) name:
1629+
1630+
```js
1631+
{
1632+
type: 'sfsymbol',
1633+
name: 'pencil',
1634+
}
1635+
```
1636+
15931637
- `items`: An array of menu items (can be either `action` or `submenu`).
15941638

15951639
Example:
15961640

15971641
```js
1598-
unstable_headerLeftItems: () => [
1642+
unstable_headerRightItems: () => [
15991643
{
16001644
type: 'menu',
16011645
label: 'Options',
1646+
icon: {
1647+
type: 'sfsymbol',
1648+
name: 'ellipsis',
1649+
},
16021650
menu: {
16031651
title: 'Options',
16041652
items: [
16051653
{
16061654
type: 'action',
16071655
label: 'Edit',
1656+
icon: {
1657+
type: 'sfsymbol',
1658+
name: 'pencil',
1659+
},
16081660
onPress: () => {
16091661
// Do something
16101662
},
@@ -1639,7 +1691,7 @@ Supported properties:
16391691
- `spacing`: Amount of spacing to add.
16401692

16411693
```js
1642-
unstable_headerLeftItems: () => [
1694+
unstable_headerRightItems: () => [
16431695
{
16441696
type: 'button',
16451697
label: 'Edit',
@@ -1674,7 +1726,7 @@ Supported properties:
16741726
Example:
16751727

16761728
```js
1677-
unstable_headerLeftItems: () => [
1729+
unstable_headerRightItems: () => [
16781730
{
16791731
type: 'custom',
16801732
element: <MaterialCommunityIcons name="map" color="gray" size={36} />,

0 commit comments

Comments
 (0)