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
+254-2Lines changed: 254 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -415,7 +415,12 @@ Tint color for the header. Changes the color of back button and title.
415
415
416
416
#### `headerLeft`
417
417
418
-
Function which returns a React Element to display on the left side of the header. This replaces the back button. See `headerBackVisible` to show the back button along side left element.
418
+
Function which returns a React Element to display on the left side of the header. This replaces the back button. See `headerBackVisible` to show the back button along side left element. It receives the following properties in the arguments:
419
+
420
+
-`tintColor` - The tint color to apply. Defaults to the [theme](themes.md)'s primary color.
421
+
-`canGoBack` - Boolean indicating whether there is a screen to go back to.
422
+
-`label` - Label text for the button. Usually the title of the previous screen.
423
+
-`href` - The `href` to use for the anchor tag on web
This option is experimental and may change in a minor release.
442
+
443
+
:::
444
+
445
+
Function which returns an array of items to display as on the left side of the header. This will override `headerLeft` if both are specified. It receives the following properties in the arguments:
446
+
447
+
-`tintColor` - The tint color to apply. Defaults to the [theme](themes.md)'s primary color.
448
+
-`canGoBack` - Boolean indicating whether there is a screen to go back to.
449
+
450
+
Example:
451
+
452
+
```js
453
+
unstable_headerLeftItems: () => [
454
+
{
455
+
type:'button',
456
+
title:'Edit',
457
+
onPress: () => {
458
+
// Do something
459
+
},
460
+
},
461
+
],
462
+
```
463
+
464
+
See [Header items](#header-items) for more information.
465
+
466
+
Only supported on iOS.
467
+
432
468
#### `headerRight`
433
469
434
-
Function which returns a React Element to display on the right side of the header.
470
+
Function which returns a React Element to display on the right side of the header. It receives the following properties in the arguments:
471
+
472
+
-`tintColor` - The tint color to apply. Defaults to the [theme](themes.md)'s primary color.
473
+
-`canGoBack` - Boolean indicating whether there is a screen to go back to.
This option is experimental and may change in a minor release.
488
+
489
+
:::
490
+
491
+
Function which returns an array of items to display as on the right side of the header. This will override `headerRight` if both are specified. It receives the following properties in the arguments:
492
+
493
+
-`tintColor` - The tint color to apply. Defaults to the [theme](themes.md)'s primary color.
494
+
-`canGoBack` - Boolean indicating whether there is a screen to go back to.
495
+
496
+
Example:
497
+
498
+
```js
499
+
unstable_headerRightItems: () => [
500
+
{
501
+
type:'button',
502
+
title:'Edit',
503
+
onPress: () => {
504
+
// Do something
505
+
},
506
+
},
507
+
],
508
+
```
509
+
510
+
See [Header items](#header-items) for more information.
511
+
512
+
Only supported on iOS.
513
+
444
514
#### `headerTitle`
445
515
446
516
String or a function that returns a React Element to be used by the header. Defaults to `title` or name of the screen.
@@ -1430,3 +1500,185 @@ const MyView = () => {
1430
1500
);
1431
1501
};
1432
1502
```
1503
+
1504
+
## Header items
1505
+
1506
+
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.
1507
+
1508
+
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.
<imgsrc="/assets/header-items/header-items-menu.png"width="300"alt="Header item with menu" />
1513
+
1514
+
There are 3 categories of items that can be displayed in the header:
1515
+
1516
+
### Action
1517
+
1518
+
A regular button that performs an action when pressed, or shows a menu.
1519
+
1520
+
Common properties:
1521
+
1522
+
-`type`: Must be `button` or `menu`.
1523
+
-`label`: Label of the item. The label is not shown if `icon` is specified. However, it is used by screen readers, or if the header items get collapsed due to lack of space.
1524
+
-`labelStyle`: Style object for the label. Supported properties:
1525
+
-`fontFamily`
1526
+
-`fontSize`
1527
+
-`fontWeight`
1528
+
-`color`
1529
+
-`icon`: Optional icon to show instead of the label.
1530
+
-`variant`: Visual variant of the button. Supported values:
1531
+
-`plain` (default)
1532
+
-`done`
1533
+
-`prominent`
1534
+
-`tintColor`: Tint color to apply to the item.
1535
+
-`disabled`: Whether the item is disabled.
1536
+
-`width`: Width of the item.
1537
+
-`hidesSharedBackground` (iOS 26+): Whether the background this item may share with other items should be hidden. Setting this to `true` hides the liquid glass background.
1538
+
-`sharesBackground` (iOS 26+): Whether this item can share a background with other items.
1539
+
-`identifier` (iOS 26+) - An identifier used to match items across transitions.
1540
+
-`badge`: An optional badge to display alongside the item. Supported properties:
1541
+
-`value`: The value to display in the badge. It can be a string or a number.
1542
+
-`style`: Style object for the badge. Supported properties:
1543
+
-`fontFamily`
1544
+
-`fontSize`
1545
+
-`fontWeight`
1546
+
-`color`
1547
+
-`accessibilityLabel`: Accessibility label for the item.
1548
+
-`accessibilityHint`: Accessibility hint for the item.
1549
+
1550
+
Supported properties when `type` is `button`:
1551
+
1552
+
-`onPress`: Function to call when the button is pressed.
1553
+
-`selected`: Whether the button is in a selected state.
1554
+
1555
+
Example:
1556
+
1557
+
```js
1558
+
unstable_headerLeftItems: () => [
1559
+
{
1560
+
type:'button',
1561
+
label:'Edit',
1562
+
onPress: () => {
1563
+
// Do something
1564
+
},
1565
+
},
1566
+
],
1567
+
```
1568
+
1569
+
Supported properties when `type` is `menu`:
1570
+
1571
+
-`menu`: An object containing the menu items. It contains the following properties:
1572
+
-`title`: Optional title to show on top of the menu.
1573
+
-`items`: An array of menu items. A menu item can be either an `action` or a `submenu`.
1574
+
-`action`: An object with the following properties:
1575
+
-`type`: Must be `action`.
1576
+
-`label`: Label of the menu item.
1577
+
-`icon`: Optional icon to show alongside the label.
1578
+
-`onPress`: Function to call when the menu item is pressed.
1579
+
-`state`: Optional state of the menu item. Supported values:
1580
+
-`on`
1581
+
-`off`
1582
+
-`mixed`
1583
+
-`disabled`: Whether the menu item is disabled.
1584
+
-`destructive`: Whether the menu item is styled as destructive.
1585
+
-`hidden`: Whether the menu item is hidden.
1586
+
-`keepsMenuPresented`: Whether to keep the menu open after selecting this item. Defaults to `false`.
1587
+
-`discoverabilityLabel`: An elaborated title that explains the purpose of the action.
1588
+
-`submenu`: An object with the following properties:
1589
+
-`type`: Must be `submenu`.
1590
+
-`label`: Label of the submenu item.
1591
+
-`icon`: Optional icon to show alongside the label.
1592
+
-`items`: An array of menu items (can be either `action` or `submenu`).
1593
+
1594
+
Example:
1595
+
1596
+
```js
1597
+
unstable_headerLeftItems: () => [
1598
+
{
1599
+
type:'menu',
1600
+
label:'Options',
1601
+
menu: {
1602
+
title:'Options',
1603
+
items: [
1604
+
{
1605
+
type:'action',
1606
+
label:'Edit',
1607
+
onPress: () => {
1608
+
// Do something
1609
+
},
1610
+
},
1611
+
{
1612
+
type:'submenu',
1613
+
label:'More',
1614
+
items: [
1615
+
{
1616
+
type:'action',
1617
+
label:'Delete',
1618
+
destructive:true,
1619
+
onPress: () => {
1620
+
// Do something
1621
+
},
1622
+
},
1623
+
],
1624
+
},
1625
+
],
1626
+
},
1627
+
},
1628
+
],
1629
+
```
1630
+
1631
+
### Spacing
1632
+
1633
+
An item to add spacing between other items in the header.
1634
+
1635
+
Supported properties:
1636
+
1637
+
-`type`: Must be `spacing`.
1638
+
-`spacing`: Amount of spacing to add.
1639
+
1640
+
```js
1641
+
unstable_headerLeftItems: () => [
1642
+
{
1643
+
type:'button',
1644
+
label:'Edit',
1645
+
onPress: () => {
1646
+
// Do something
1647
+
},
1648
+
},
1649
+
{
1650
+
type:'spacing',
1651
+
spacing:10,
1652
+
},
1653
+
{
1654
+
type:'button',
1655
+
label:'Delete',
1656
+
onPress: () => {
1657
+
// Do something
1658
+
},
1659
+
},
1660
+
],
1661
+
```
1662
+
1663
+
### Custom
1664
+
1665
+
A custom item to display any React Element in the header.
1666
+
1667
+
Supported properties:
1668
+
1669
+
-`type`: Must be `custom`.
1670
+
-`element`: A React Element to display as the item.
1671
+
-`hidesSharedBackground`: Whether the background this item may share with other items in the bar should be hidden. Setting this to `true` hides the liquid glass background on iOS 26+.
The advantage of using this over [`headerLeft`](#headerleft) or [`headerRight`](#headerright) options is it supports features like shared background on iOS 26+.
0 commit comments