Skip to content

Commit a5179d7

Browse files
committed
Add example for blur in header
1 parent f086b8a commit a5179d7

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

docs/stack-navigator.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,9 @@ header: ({ scene, previous, navigation }) => {
172172
When using a custom header, it's recommended set the `headerMode` prop on the navigator to `screen`. You should also specify a height in `headerStyle` to avoid glitches:
173173

174174
```js
175-
headerStyle: { height: 80 } // Specify the height of your custom header
175+
headerStyle: {
176+
height: 80, // Specify the height of your custom header
177+
};
176178
```
177179

178180
To set a custom header for all the screens in the navigator, you can specify this option in the `screenOptions` prop of the navigator.
@@ -282,7 +284,24 @@ const headerHeight = useHeaderHeight();
282284

283285
Function which returns a React Element to render as the background of the header. This is useful for using backgrounds such as an image or a gradient.
284286

285-
You can use this with `headerTransparent` to render a blur view, for example, to create a translucent header.
287+
For example, you can use this with `headerTransparent` to render a blur view to create a translucent header.
288+
289+
```js
290+
import { BlurView } from 'expo-blur';
291+
292+
// ...
293+
294+
<Screen
295+
name="Home"
296+
component={HomeScreen}
297+
options={{
298+
headerTransparent: true,
299+
headerBackground: () => (
300+
<BlurView tint="light" intensity={100} style={StyleSheet.absoluteFill} />
301+
),
302+
}}
303+
/>;
304+
```
286305

287306
#### `headerStatusBarHeight`
288307

website/versioned_docs/version-4.x/stack-navigator.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ header: ({ scene, previous, navigation }) => {
106106
When using a custom header, it's recommended set the `headerMode` option on the navigator to `screen`. You should also specify a height in `headerStyle` to avoid glitches:
107107

108108
```js
109-
headerStyle: { height: 80 } // Specify the height of your custom header
109+
headerStyle: {
110+
height: 80, // Specify the height of your custom header
111+
};
110112
```
111113

112114
To set a custom header for all the screens in the navigator, you can specify this option in the `defaultNavigationOptions` option of the navigator.
@@ -216,7 +218,20 @@ const headerHeight = useHeaderHeight();
216218

217219
Function which returns a React Element to render as the background of the header. This is useful for using backgrounds such as an image or a gradient.
218220

219-
You can use this with `headerTransparent` to render a blur view, for example, to create a translucent header.
221+
For example, you can use this with `headerTransparent` to render a blur view to create a translucent header.
222+
223+
```js
224+
import { BlurView } from 'expo-blur';
225+
226+
// ...
227+
228+
MyScreen.navigationOptions = {
229+
headerTransparent: true,
230+
headerBackground: () => (
231+
<BlurView tint="light" intensity={100} style={StyleSheet.absoluteFill} />
232+
),
233+
};
234+
```
220235

221236
#### `headerStatusBarHeight`
222237

0 commit comments

Comments
 (0)