Skip to content

Commit 045a0ae

Browse files
committed
docs: updated header documentation
1 parent c0fb706 commit 045a0ae

File tree

1 file changed

+40
-5
lines changed

1 file changed

+40
-5
lines changed

docs/docs/03-api-reference/components/04-header.mdx

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ slug: /components/header
55
description: A header navigation component exported from React Native Header.
66
---
77

8-
Headers are navigation components that display information and actions relating to the current
9-
screen. This component is exported in this library and works well with the other scroll
8+
Headers are navigation components that display information and actions relating to the current
9+
screen. This component is exported in this library and works well with the other scroll
1010
containers this library provides.
1111

1212
## Props
@@ -61,8 +61,8 @@ An optional boolean to indicate whether the header's center container should fad
6161
### ignoreTopSafeArea
6262

6363
An optional boolean to indicate whether the header should ignore the top safe area. This is useful
64-
when you want to display the header behind the status bar. Defaults to `false`. If you are
65-
rendering this header in an iOS [modal](https://reactnavigation.org/docs/native-stack-navigator/#presentation),
64+
when you want to display the header behind the status bar. Defaults to `false`. If you are
65+
rendering this header in an iOS [modal](https://reactnavigation.org/docs/native-stack-navigator/#presentation),
6666
you should set this to `true`.
6767

6868
### noBottomBorder
@@ -76,4 +76,39 @@ An optional color to use for the header's bottom border. Defaults to `#E5E5E5`.
7676

7777
### borderWidth
7878

79-
An optional width to use for the header's bottom border. Defaults to [StyleSheet.hairlineWidth](https://reactnative.dev/docs/stylesheet#hairlinewidth).
79+
An optional width to use for the header's bottom border. Defaults to [StyleSheet.hairlineWidth](https://reactnative.dev/docs/stylesheet#hairlinewidth).
80+
81+
### SurfaceComponent
82+
83+
An optional component that can act as the surface of the header. Please ensure that the styling applied to the component includes `StyleSheet.absoluteFill` or `StyleSheet.absoluteFillObject` to ensure that the surface component fills the header.
84+
85+
#### Example
86+
87+
The following example will make the header have a **cyan** background when the user scrolls the scroll container up:
88+
89+
```jsx
90+
const SURFACE_BG_COLOR = 'cyan';
91+
92+
const HeaderSurface: React.FC<SurfaceComponentProps> = ({ showNavBar }) => (
93+
<FadingView
94+
opacity={showNavBar}
95+
// StyleSheet.absoluteFill is needed to ensure that the component fills up the header.
96+
style={[StyleSheet.absoluteFill, { backgroundColor: SURFACE_BG_COLOR }]}
97+
/>
98+
);
99+
100+
const HeaderComponent: React.FC<ScrollHeaderProps> = ({ showNavBar }) => {
101+
const navigation = useNavigation();
102+
const onPressProfile = () => navigation.navigate('Profile');
103+
104+
return (
105+
<Header
106+
showNavBar={showNavBar}
107+
// ...
108+
SurfaceComponent={HeaderSurface} // <- usage
109+
/>
110+
);
111+
};
112+
```
113+
114+
See the example application's _Header SurfaceComponent Interpolation_ screen in for a working example.

0 commit comments

Comments
 (0)