Skip to content

Commit 9b75d83

Browse files
committed
Add documentation for document title
1 parent cd8f7bb commit 9b75d83

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

versioned_docs/version-5.x/navigation-container.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,41 @@ See [configuring links guide](configuring-links.md) for more details on how to c
120120
121121
React Element to use as a fallback while we resolve the deep link. Defaults to `null`.
122122
123+
### `documentTitle`
124+
125+
By default, React Navigation automatically updates the document title on Web to match the `title` option of the focused screen. You can disable it or customize it using this prop. It accepts a configuration object with the following options:
126+
127+
#### `enabled`
128+
129+
Whether document title handling should be enabled. Defaults to `true`.
130+
131+
#### `formatter`
132+
133+
Custom formatter to use if you want to customize the title text. Defaults to:
134+
135+
```js
136+
(options, route) => options?.title ?? route?.name;
137+
```
138+
139+
Example:
140+
141+
```js
142+
import { NavigationContainer } from '@react-navigation/native';
143+
144+
function App() {
145+
return (
146+
<NavigationContainer
147+
documentTitle={{
148+
formatter: (options, route) =>
149+
`${options?.title ?? route?.name} - My Cool App`,
150+
}}
151+
>
152+
{/* content */}
153+
</NavigationContainer>
154+
);
155+
}
156+
```
157+
123158
### `theme`
124159
125160
Custom theme to use for the navigation components such as the header, tab bar etc. See [theming guide](themes.md) for more details and usage guide.

0 commit comments

Comments
 (0)