agentic-mobile-kit 0.0.2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -8
- package/bin/cli.js +31 -5
- package/lib/init.js +199 -0
- package/package.json +9 -3
- package/stacks/react-native/template/.agents/skills/LICENSE-callstack +21 -0
- package/stacks/react-native/template/.agents/skills/THIRD_PARTY.md +9 -0
- package/stacks/react-native/template/.agents/skills/m-bugfix/SKILL.md +23 -0
- package/stacks/react-native/template/.agents/skills/m-bugfix/agents/openai.yaml +3 -0
- package/stacks/react-native/template/.agents/skills/m-continue/SKILL.md +22 -0
- package/stacks/react-native/template/.agents/skills/m-continue/agents/openai.yaml +3 -0
- package/stacks/react-native/template/.agents/skills/m-feature/SKILL.md +50 -0
- package/stacks/react-native/template/.agents/skills/m-feature/agents/openai.yaml +3 -0
- package/stacks/react-native/template/.agents/skills/m-pause/SKILL.md +14 -0
- package/stacks/react-native/template/.agents/skills/m-pause/agents/openai.yaml +3 -0
- package/stacks/react-native/template/.agents/skills/m-review/SKILL.md +29 -0
- package/stacks/react-native/template/.agents/skills/m-review/agents/openai.yaml +3 -0
- package/stacks/react-native/template/.agents/skills/react-native-best-practices/POWER.md +172 -0
- package/stacks/react-native/template/.agents/skills/react-native-best-practices/SKILL.md +238 -0
- package/stacks/react-native/template/.agents/skills/react-native-best-practices/agents/openai.yaml +4 -0
- package/stacks/react-native/template/.agents/skills/react-native-best-practices/references/bundle-analyze-app.md +208 -0
- package/stacks/react-native/template/.agents/skills/react-native-best-practices/references/bundle-analyze-js.md +264 -0
- package/stacks/react-native/template/.agents/skills/react-native-best-practices/references/bundle-barrel-exports.md +250 -0
- package/stacks/react-native/template/.agents/skills/react-native-best-practices/references/bundle-code-splitting.md +255 -0
- package/stacks/react-native/template/.agents/skills/react-native-best-practices/references/bundle-hermes-mmap.md +167 -0
- package/stacks/react-native/template/.agents/skills/react-native-best-practices/references/bundle-library-size.md +164 -0
- package/stacks/react-native/template/.agents/skills/react-native-best-practices/references/bundle-native-assets.md +208 -0
- package/stacks/react-native/template/.agents/skills/react-native-best-practices/references/bundle-r8-android.md +231 -0
- package/stacks/react-native/template/.agents/skills/react-native-best-practices/references/bundle-tree-shaking.md +215 -0
- package/stacks/react-native/template/.agents/skills/react-native-best-practices/references/js-animations-reanimated.md +273 -0
- package/stacks/react-native/template/.agents/skills/react-native-best-practices/references/js-atomic-state.md +190 -0
- package/stacks/react-native/template/.agents/skills/react-native-best-practices/references/js-bottomsheet.md +339 -0
- package/stacks/react-native/template/.agents/skills/react-native-best-practices/references/js-concurrent-react.md +238 -0
- package/stacks/react-native/template/.agents/skills/react-native-best-practices/references/js-lists-flatlist-flashlist.md +223 -0
- package/stacks/react-native/template/.agents/skills/react-native-best-practices/references/js-measure-fps.md +178 -0
- package/stacks/react-native/template/.agents/skills/react-native-best-practices/references/js-memory-leaks.md +168 -0
- package/stacks/react-native/template/.agents/skills/react-native-best-practices/references/js-profile-react.md +138 -0
- package/stacks/react-native/template/.agents/skills/react-native-best-practices/references/js-react-compiler.md +261 -0
- package/stacks/react-native/template/.agents/skills/react-native-best-practices/references/js-uncontrolled-components.md +219 -0
- package/stacks/react-native/template/.agents/skills/react-native-best-practices/references/native-android-16kb-alignment.md +114 -0
- package/stacks/react-native/template/.agents/skills/react-native-best-practices/references/native-measure-tti.md +221 -0
- package/stacks/react-native/template/.agents/skills/react-native-best-practices/references/native-memory-leaks.md +206 -0
- package/stacks/react-native/template/.agents/skills/react-native-best-practices/references/native-memory-patterns.md +240 -0
- package/stacks/react-native/template/.agents/skills/react-native-best-practices/references/native-platform-setup.md +112 -0
- package/stacks/react-native/template/.agents/skills/react-native-best-practices/references/native-profiling.md +140 -0
- package/stacks/react-native/template/.agents/skills/react-native-best-practices/references/native-sdks-over-polyfills.md +192 -0
- package/stacks/react-native/template/.agents/skills/react-native-best-practices/references/native-threading-model.md +230 -0
- package/stacks/react-native/template/.agents/skills/react-native-best-practices/references/native-turbo-modules.md +210 -0
- package/stacks/react-native/template/.agents/skills/react-native-best-practices/references/native-view-flattening.md +180 -0
- package/stacks/react-native/template/.agents/skills/react-navigation/SKILL.md +63 -0
- package/stacks/react-native/template/.agents/skills/react-navigation/agents/openai.yaml +4 -0
- package/stacks/react-native/template/.agents/skills/react-navigation/references/bottom-tabs.md +496 -0
- package/stacks/react-native/template/.agents/skills/react-navigation/references/drawers.md +474 -0
- package/stacks/react-native/template/.agents/skills/react-navigation/references/form-sheet.md +305 -0
- package/stacks/react-native/template/.agents/skills/react-navigation/references/header.md +270 -0
- package/stacks/react-native/template/.agents/skills/react-navigation/references/material-top-tabs.md +453 -0
- package/stacks/react-native/template/.agents/skills/react-navigation/references/native-bottom-tabs.md +365 -0
- package/stacks/react-native/template/.agents/skills/react-navigation/references/safe-areas.md +95 -0
- package/stacks/react-native/template/.agents/skills/react-navigation/references/stacks.md +392 -0
- package/stacks/react-native/template/.agents/skills/upgrading-react-native/SKILL.md +79 -0
- package/stacks/react-native/template/.agents/skills/upgrading-react-native/agents/openai.yaml +4 -0
- package/stacks/react-native/template/.agents/skills/upgrading-react-native/references/expo-sdk-upgrade.md +65 -0
- package/stacks/react-native/template/.agents/skills/upgrading-react-native/references/monorepo-singlerepo-targeting.md +34 -0
- package/stacks/react-native/template/.agents/skills/upgrading-react-native/references/react.md +42 -0
- package/stacks/react-native/template/.agents/skills/upgrading-react-native/references/upgrade-helper-core.md +122 -0
- package/stacks/react-native/template/.agents/skills/upgrading-react-native/references/upgrade-verification.md +53 -0
- package/stacks/react-native/template/.agents/skills/upgrading-react-native/references/upgrading-dependencies.md +41 -0
- package/stacks/react-native/template/.agents/skills/upgrading-react-native/references/upgrading-react-native.md +52 -0
- package/stacks/react-native/template/.githooks/pre-commit +49 -0
- package/stacks/react-native/template/.githooks/pre-push +5 -0
- package/stacks/react-native/template/.github/pull_request_template.md +19 -0
- package/stacks/react-native/template/.github/workflows/ci.yml +61 -0
- package/stacks/react-native/template/.github/workflows/ios.yml +43 -0
- package/stacks/react-native/template/.gitleaks.toml +12 -0
- package/stacks/react-native/template/.rulesync/hooks.jsonc +8 -0
- package/stacks/react-native/template/.rulesync/permissions.jsonc +36 -0
- package/stacks/react-native/template/.rulesync/subagents/m-reviewer.md +15 -0
- package/stacks/react-native/template/AGENTS.md +45 -0
- package/stacks/react-native/template/CLAUDE.md +1 -0
- package/stacks/react-native/template/docs/ai/conventions.md +8 -0
- package/stacks/react-native/template/docs/ai/decisions.md +6 -0
- package/stacks/react-native/template/docs/ai/known-issues.md +17 -0
- package/stacks/react-native/template/docs/ai/product.md +7 -0
- package/stacks/react-native/template/docs/ai/react-native.md +27 -0
- package/stacks/react-native/template/docs/ai/structure.md +7 -0
- package/stacks/react-native/template/docs/ai/team-process.md +9 -0
- package/stacks/react-native/template/docs/ai/tech.md +7 -0
- package/stacks/react-native/template/rulesync.jsonc +9 -0
- package/stacks/react-native/template/scripts/ai/guard.js +35 -0
- package/stacks/react-native/template/scripts/ai/handoff-check.js +28 -0
- package/stacks/react-native/template/scripts/ai/install-deps.sh +14 -0
- package/stacks/react-native/template/scripts/ai/ios-build.sh +11 -0
- package/stacks/react-native/template/scripts/ai/pm-run.sh +16 -0
- package/stacks/react-native/template/specs/_templates/design.md +15 -0
- package/stacks/react-native/template/specs/_templates/progress.md +14 -0
- package/stacks/react-native/template/specs/_templates/requirements.md +30 -0
- package/stacks/react-native/template/specs/_templates/tasks.md +6 -0
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Form Sheets with Native Stack
|
|
3
|
+
impact: MEDIUM
|
|
4
|
+
tags: react-navigation, native-stack, form-sheet, bottom-sheet, modal, detents
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Skill: Form Sheets with Native Stack
|
|
8
|
+
|
|
9
|
+
## Description
|
|
10
|
+
|
|
11
|
+
Use native-stack `presentation: 'formSheet'` when a screen should open as a sheet.
|
|
12
|
+
|
|
13
|
+
## When to Use
|
|
14
|
+
|
|
15
|
+
- Presenting secondary flows such as edit forms, filters, pickers, or lightweight detail screens
|
|
16
|
+
- Keeping the current screen visible underneath a native sheet presentation
|
|
17
|
+
|
|
18
|
+
## Basic Example
|
|
19
|
+
|
|
20
|
+
**Static API**
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
|
24
|
+
|
|
25
|
+
const AppStack = createNativeStackNavigator({
|
|
26
|
+
screens: {
|
|
27
|
+
Home: HomeScreen,
|
|
28
|
+
EditProfile: {
|
|
29
|
+
screen: EditProfileScreen,
|
|
30
|
+
options: {
|
|
31
|
+
presentation: 'formSheet',
|
|
32
|
+
headerShown: false,
|
|
33
|
+
sheetAllowedDetents: 'fitToContents',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Dynamic API**
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
|
44
|
+
|
|
45
|
+
const Stack = createNativeStackNavigator();
|
|
46
|
+
|
|
47
|
+
function AppStack() {
|
|
48
|
+
return (
|
|
49
|
+
<Stack.Navigator>
|
|
50
|
+
<Stack.Screen name="Home" component={HomeScreen} />
|
|
51
|
+
<Stack.Screen
|
|
52
|
+
name="EditProfile"
|
|
53
|
+
component={EditProfileScreen}
|
|
54
|
+
options={{
|
|
55
|
+
presentation: 'formSheet',
|
|
56
|
+
headerShown: false,
|
|
57
|
+
sheetAllowedDetents: 'fitToContents',
|
|
58
|
+
}}
|
|
59
|
+
/>
|
|
60
|
+
</Stack.Navigator>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Configuring Sheet Sizes
|
|
66
|
+
|
|
67
|
+
By default, a form sheet takes the full screen height. Use `sheetAllowedDetents` to control the heights where the sheet can rest.
|
|
68
|
+
|
|
69
|
+
- Use `'fitToContents'` to size the sheet from its content.
|
|
70
|
+
- Use an ascending array of fractions such as `[0.25, 0.5, 1]` for fixed detents.
|
|
71
|
+
- On Android, only the first 3 detents are used.
|
|
72
|
+
- Use `sheetInitialDetentIndex` to choose the opening detent, or `'last'` for the largest one.
|
|
73
|
+
|
|
74
|
+
### Fit to Contents
|
|
75
|
+
|
|
76
|
+
`sheetResizeAnimationEnabled` is Android only and controls the default resize animation when using `'fitToContents'`.
|
|
77
|
+
|
|
78
|
+
**Static API**
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
|
82
|
+
|
|
83
|
+
const AppStack = createNativeStackNavigator({
|
|
84
|
+
screens: {
|
|
85
|
+
Home: HomeScreen,
|
|
86
|
+
Filters: {
|
|
87
|
+
screen: FiltersScreen,
|
|
88
|
+
options: {
|
|
89
|
+
presentation: 'formSheet',
|
|
90
|
+
sheetAllowedDetents: 'fitToContents',
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**Dynamic API**
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
|
101
|
+
|
|
102
|
+
const Stack = createNativeStackNavigator();
|
|
103
|
+
|
|
104
|
+
function AppStack() {
|
|
105
|
+
return (
|
|
106
|
+
<Stack.Navigator>
|
|
107
|
+
<Stack.Screen name="Home" component={HomeScreen} />
|
|
108
|
+
<Stack.Screen
|
|
109
|
+
name="Filters"
|
|
110
|
+
component={FiltersScreen}
|
|
111
|
+
options={{
|
|
112
|
+
presentation: 'formSheet',
|
|
113
|
+
sheetAllowedDetents: 'fitToContents',
|
|
114
|
+
}}
|
|
115
|
+
/>
|
|
116
|
+
</Stack.Navigator>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
On iOS, a top-level `flex: 1` content container works with `'fitToContents'`.
|
|
122
|
+
|
|
123
|
+
On Android, `'fitToContents'` does not work with a top-level `flex: 1` content container. The sheet can disappear and leave only the dimmed backdrop visible.
|
|
124
|
+
|
|
125
|
+
### Fixed Detents and Initial Detent
|
|
126
|
+
|
|
127
|
+
`sheetShouldOverflowTopInset` is Android only and changes whether detent fractions are measured against the full stack height or the inset-adjusted height.
|
|
128
|
+
|
|
129
|
+
**Static API**
|
|
130
|
+
|
|
131
|
+
```tsx
|
|
132
|
+
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
|
133
|
+
|
|
134
|
+
const AppStack = createNativeStackNavigator({
|
|
135
|
+
screens: {
|
|
136
|
+
Home: HomeScreen,
|
|
137
|
+
Details: {
|
|
138
|
+
screen: DetailsScreen,
|
|
139
|
+
options: {
|
|
140
|
+
presentation: 'formSheet',
|
|
141
|
+
sheetAllowedDetents: [0.25, 0.5, 1],
|
|
142
|
+
sheetInitialDetentIndex: 1,
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
**Dynamic API**
|
|
150
|
+
|
|
151
|
+
```tsx
|
|
152
|
+
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
|
153
|
+
|
|
154
|
+
const Stack = createNativeStackNavigator();
|
|
155
|
+
|
|
156
|
+
function AppStack() {
|
|
157
|
+
return (
|
|
158
|
+
<Stack.Navigator>
|
|
159
|
+
<Stack.Screen name="Home" component={HomeScreen} />
|
|
160
|
+
<Stack.Screen
|
|
161
|
+
name="Details"
|
|
162
|
+
component={DetailsScreen}
|
|
163
|
+
options={{
|
|
164
|
+
presentation: 'formSheet',
|
|
165
|
+
sheetAllowedDetents: [0.25, 0.5, 1],
|
|
166
|
+
sheetInitialDetentIndex: 1,
|
|
167
|
+
}}
|
|
168
|
+
/>
|
|
169
|
+
</Stack.Navigator>
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
On iOS, fixed detents do not automatically make content fill the sheet height. Use `contentStyle.backgroundColor` if the uncovered area would otherwise look translucent.
|
|
175
|
+
|
|
176
|
+
## Customizing Appearance
|
|
177
|
+
|
|
178
|
+
- `sheetGrabberVisible` is iOS only and shows the grabber.
|
|
179
|
+
- `sheetCornerRadius` overrides the default corner radius.
|
|
180
|
+
- `sheetElevation` is Android only, adjusts the top-edge shadow, and cannot be changed after mount.
|
|
181
|
+
- `sheetLargestUndimmedDetentIndex` controls when the background stays undimmed: `'none'` always dims, `'last'` never dims, and a number keeps the background undimmed up to that detent index. On iOS, the system can still add dimming if the sheet grows beyond that height without a detent change, such as when the keyboard appears.
|
|
182
|
+
- `contentStyle.backgroundColor` sets an explicit background color for the whole sheet. This is especially useful on iOS with fixed detents, where the content does not automatically fill the sheet height.
|
|
183
|
+
|
|
184
|
+
**Static API**
|
|
185
|
+
|
|
186
|
+
```tsx
|
|
187
|
+
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
|
188
|
+
|
|
189
|
+
const AppStack = createNativeStackNavigator({
|
|
190
|
+
screens: {
|
|
191
|
+
Home: HomeScreen,
|
|
192
|
+
Composer: {
|
|
193
|
+
screen: ComposerScreen,
|
|
194
|
+
options: {
|
|
195
|
+
presentation: 'formSheet',
|
|
196
|
+
sheetAllowedDetents: [0.5, 1],
|
|
197
|
+
sheetGrabberVisible: true,
|
|
198
|
+
sheetCornerRadius: 24,
|
|
199
|
+
sheetElevation: 12,
|
|
200
|
+
sheetLargestUndimmedDetentIndex: 0,
|
|
201
|
+
contentStyle: {
|
|
202
|
+
backgroundColor: '#fff',
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
**Dynamic API**
|
|
211
|
+
|
|
212
|
+
```tsx
|
|
213
|
+
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
|
214
|
+
|
|
215
|
+
const Stack = createNativeStackNavigator();
|
|
216
|
+
|
|
217
|
+
function AppStack() {
|
|
218
|
+
return (
|
|
219
|
+
<Stack.Navigator>
|
|
220
|
+
<Stack.Screen name="Home" component={HomeScreen} />
|
|
221
|
+
<Stack.Screen
|
|
222
|
+
name="Composer"
|
|
223
|
+
component={ComposerScreen}
|
|
224
|
+
options={{
|
|
225
|
+
presentation: 'formSheet',
|
|
226
|
+
sheetAllowedDetents: [0.5, 1],
|
|
227
|
+
sheetGrabberVisible: true,
|
|
228
|
+
sheetCornerRadius: 24,
|
|
229
|
+
sheetElevation: 12,
|
|
230
|
+
sheetLargestUndimmedDetentIndex: 0,
|
|
231
|
+
contentStyle: {
|
|
232
|
+
backgroundColor: '#fff',
|
|
233
|
+
},
|
|
234
|
+
}}
|
|
235
|
+
/>
|
|
236
|
+
</Stack.Navigator>
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## Scroll Behavior
|
|
242
|
+
|
|
243
|
+
On iOS, scrolling can expand the sheet to a larger detent by default. `sheetExpandsWhenScrolledToEdge` is iOS only, and setting it to `false` prevents that behavior.
|
|
244
|
+
|
|
245
|
+
For this to work, the `ScrollView` must be reachable by following the first child at each level from the screen component (aka first descendant chain).
|
|
246
|
+
|
|
247
|
+
**Static API**
|
|
248
|
+
|
|
249
|
+
```tsx
|
|
250
|
+
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
|
251
|
+
|
|
252
|
+
const AppStack = createNativeStackNavigator({
|
|
253
|
+
screens: {
|
|
254
|
+
Home: HomeScreen,
|
|
255
|
+
Comments: {
|
|
256
|
+
screen: CommentsScreen,
|
|
257
|
+
options: {
|
|
258
|
+
presentation: 'formSheet',
|
|
259
|
+
sheetAllowedDetents: [0.5, 1],
|
|
260
|
+
sheetExpandsWhenScrolledToEdge: false,
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
});
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
**Dynamic API**
|
|
268
|
+
|
|
269
|
+
```tsx
|
|
270
|
+
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
|
271
|
+
|
|
272
|
+
const Stack = createNativeStackNavigator();
|
|
273
|
+
|
|
274
|
+
function AppStack() {
|
|
275
|
+
return (
|
|
276
|
+
<Stack.Navigator>
|
|
277
|
+
<Stack.Screen name="Home" component={HomeScreen} />
|
|
278
|
+
<Stack.Screen
|
|
279
|
+
name="Comments"
|
|
280
|
+
component={CommentsScreen}
|
|
281
|
+
options={{
|
|
282
|
+
presentation: 'formSheet',
|
|
283
|
+
sheetAllowedDetents: [0.5, 1],
|
|
284
|
+
sheetExpandsWhenScrolledToEdge: false,
|
|
285
|
+
}}
|
|
286
|
+
/>
|
|
287
|
+
</Stack.Navigator>
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
On Android, nested `ScrollView` usage may require `nestedScrollEnabled`, and still does not work when the content is shorter than the scroll view.
|
|
293
|
+
|
|
294
|
+
## Notes
|
|
295
|
+
|
|
296
|
+
- On Android, `presentation: 'formSheet'` screens do not currently support nested stack navigators or `headerShown`.
|
|
297
|
+
|
|
298
|
+
## Canonical Docs
|
|
299
|
+
|
|
300
|
+
- [Native Stack Navigator](https://reactnavigation.org/docs/native-stack-navigator)
|
|
301
|
+
|
|
302
|
+
## Related Skills
|
|
303
|
+
|
|
304
|
+
- [stacks.md](./stacks.md)
|
|
305
|
+
- [safe-areas.md](./safe-areas.md)
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Header
|
|
3
|
+
impact: MEDIUM
|
|
4
|
+
tags: react-navigation, header, title, header-buttons, header-background, react-navigation-elements
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Skill: Header
|
|
8
|
+
|
|
9
|
+
## Description
|
|
10
|
+
|
|
11
|
+
Use this when customizing the header in bottom tabs or drawer which render a JS-based header.
|
|
12
|
+
|
|
13
|
+
For native stack headers, use [stacks.md](./stacks.md) instead.
|
|
14
|
+
|
|
15
|
+
## When to Use
|
|
16
|
+
|
|
17
|
+
- Styling the built-in header in bottom tabs or drawer screens
|
|
18
|
+
- Adding header buttons, custom title content, or a custom background
|
|
19
|
+
|
|
20
|
+
## Basic Example
|
|
21
|
+
|
|
22
|
+
The shared header options work the same in bottom tabs and drawer. The examples below use bottom tabs.
|
|
23
|
+
|
|
24
|
+
**Static API**
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
|
28
|
+
|
|
29
|
+
const AppTabs = createBottomTabNavigator({
|
|
30
|
+
screens: {
|
|
31
|
+
Home: {
|
|
32
|
+
screen: HomeScreen,
|
|
33
|
+
options: {
|
|
34
|
+
title: 'Home',
|
|
35
|
+
headerStyle: {
|
|
36
|
+
backgroundColor: '#fff',
|
|
37
|
+
},
|
|
38
|
+
headerTintColor: '#111',
|
|
39
|
+
headerRight: () => <HeaderAction />,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**Dynamic API**
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
|
50
|
+
|
|
51
|
+
const Tab = createBottomTabNavigator();
|
|
52
|
+
|
|
53
|
+
function AppTabs() {
|
|
54
|
+
return (
|
|
55
|
+
<Tab.Navigator>
|
|
56
|
+
<Tab.Screen
|
|
57
|
+
name="Home"
|
|
58
|
+
component={HomeScreen}
|
|
59
|
+
options={{
|
|
60
|
+
title: 'Home',
|
|
61
|
+
headerStyle: {
|
|
62
|
+
backgroundColor: '#fff',
|
|
63
|
+
},
|
|
64
|
+
headerTintColor: '#111',
|
|
65
|
+
headerRight: () => <HeaderAction />,
|
|
66
|
+
}}
|
|
67
|
+
/>
|
|
68
|
+
</Tab.Navigator>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
- Use `title`, `headerStyle`, `headerTintColor`, `headerTitleStyle`, and `headerTitleAlign` for the default header. Put shared config in navigator `screenOptions` and per-screen overrides in `options`.
|
|
74
|
+
- Use `headerShown: false` for screens that contain a navigator - the header from the child navigator should be shown instead.
|
|
75
|
+
|
|
76
|
+
## Common Features
|
|
77
|
+
|
|
78
|
+
### Buttons and Custom Content
|
|
79
|
+
|
|
80
|
+
Use `headerLeft`, `headerRight`, `headerTitle`, and `headerBackground` when the default header layout is fine but specific pieces need customization.
|
|
81
|
+
|
|
82
|
+
**Static API**
|
|
83
|
+
|
|
84
|
+
```tsx
|
|
85
|
+
import { Button, Text } from 'react-native';
|
|
86
|
+
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
|
87
|
+
|
|
88
|
+
const AppTabs = createBottomTabNavigator({
|
|
89
|
+
screens: {
|
|
90
|
+
Inbox: {
|
|
91
|
+
screen: InboxScreen,
|
|
92
|
+
options: {
|
|
93
|
+
headerLeft: ({ tintColor }) => (
|
|
94
|
+
<Button title="Edit" color={tintColor} onPress={() => {}} />
|
|
95
|
+
),
|
|
96
|
+
headerTitle: ({ tintColor, children }) => (
|
|
97
|
+
<Text style={{ color: tintColor, fontSize: 18 }}>{children}</Text>
|
|
98
|
+
),
|
|
99
|
+
headerRight: ({ tintColor }) => (
|
|
100
|
+
<Button title="Done" color={tintColor} onPress={() => {}} />
|
|
101
|
+
),
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**Dynamic API**
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
import { Button, Text } from 'react-native';
|
|
112
|
+
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
|
113
|
+
|
|
114
|
+
const Tab = createBottomTabNavigator();
|
|
115
|
+
|
|
116
|
+
function AppTabs() {
|
|
117
|
+
return (
|
|
118
|
+
<Tab.Navigator>
|
|
119
|
+
<Tab.Screen
|
|
120
|
+
name="Inbox"
|
|
121
|
+
component={InboxScreen}
|
|
122
|
+
options={{
|
|
123
|
+
headerLeft: ({ tintColor }) => (
|
|
124
|
+
<Button title="Edit" color={tintColor} onPress={() => {}} />
|
|
125
|
+
),
|
|
126
|
+
headerTitle: ({ tintColor, children }) => (
|
|
127
|
+
<Text style={{ color: tintColor, fontSize: 18 }}>{children}</Text>
|
|
128
|
+
),
|
|
129
|
+
headerRight: ({ tintColor }) => (
|
|
130
|
+
<Button title="Done" color={tintColor} onPress={() => {}} />
|
|
131
|
+
),
|
|
132
|
+
}}
|
|
133
|
+
/>
|
|
134
|
+
</Tab.Navigator>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
- `headerLeft` and `headerRight` receive props such as `tintColor`, `pressColor`, and `pressOpacity`.
|
|
140
|
+
- `headerTitle` is useful when the title needs custom typography, icons, or extra layout.
|
|
141
|
+
- Use `headerTitleContainerStyle`, `headerLeftContainerStyle`, and `headerRightContainerStyle` to customize the container styles.
|
|
142
|
+
|
|
143
|
+
### Search Bar
|
|
144
|
+
|
|
145
|
+
Use `headerSearchBarOptions` to add a search button that expands into a search input in the header. If the search configuration depends on screen state, update it with `navigation.setOptions(...)`.
|
|
146
|
+
|
|
147
|
+
**Static API**
|
|
148
|
+
|
|
149
|
+
```tsx
|
|
150
|
+
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
|
151
|
+
|
|
152
|
+
const AppTabs = createBottomTabNavigator({
|
|
153
|
+
screens: {
|
|
154
|
+
Search: {
|
|
155
|
+
screen: SearchScreen,
|
|
156
|
+
options: {
|
|
157
|
+
headerSearchBarOptions: {
|
|
158
|
+
placeholder: 'Search',
|
|
159
|
+
onChangeText: (text) => {
|
|
160
|
+
// Do something
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
**Dynamic API**
|
|
170
|
+
|
|
171
|
+
```tsx
|
|
172
|
+
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
|
173
|
+
|
|
174
|
+
const Tab = createBottomTabNavigator();
|
|
175
|
+
|
|
176
|
+
function AppTabs() {
|
|
177
|
+
return (
|
|
178
|
+
<Tab.Navigator>
|
|
179
|
+
<Tab.Screen
|
|
180
|
+
name="Search"
|
|
181
|
+
component={SearchScreen}
|
|
182
|
+
options={{
|
|
183
|
+
headerSearchBarOptions: {
|
|
184
|
+
placeholder: 'Search',
|
|
185
|
+
onChangeText: (text) => {
|
|
186
|
+
// Do something
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
}}
|
|
190
|
+
/>
|
|
191
|
+
</Tab.Navigator>
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Translucent Headers
|
|
197
|
+
|
|
198
|
+
Use `headerTransparent: true` to let content show underneath the header. Combine it with `headerBackground` for effects such as a blur, gradient, or image background.
|
|
199
|
+
|
|
200
|
+
**Static API**
|
|
201
|
+
|
|
202
|
+
```tsx
|
|
203
|
+
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
|
204
|
+
import { BlurView } from 'expo-blur';
|
|
205
|
+
import { StyleSheet } from 'react-native';
|
|
206
|
+
|
|
207
|
+
const AppTabs = createBottomTabNavigator({
|
|
208
|
+
screens: {
|
|
209
|
+
Feed: {
|
|
210
|
+
screen: FeedScreen,
|
|
211
|
+
options: {
|
|
212
|
+
headerTransparent: true,
|
|
213
|
+
headerBackground: () => (
|
|
214
|
+
<BlurView
|
|
215
|
+
tint="light"
|
|
216
|
+
intensity={100}
|
|
217
|
+
style={StyleSheet.absoluteFill}
|
|
218
|
+
/>
|
|
219
|
+
),
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
**Dynamic API**
|
|
227
|
+
|
|
228
|
+
```tsx
|
|
229
|
+
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
|
230
|
+
import { BlurView } from 'expo-blur';
|
|
231
|
+
import { StyleSheet } from 'react-native';
|
|
232
|
+
|
|
233
|
+
const Tab = createBottomTabNavigator();
|
|
234
|
+
|
|
235
|
+
function AppTabs() {
|
|
236
|
+
return (
|
|
237
|
+
<Tab.Navigator>
|
|
238
|
+
<Tab.Screen
|
|
239
|
+
name="Feed"
|
|
240
|
+
component={FeedScreen}
|
|
241
|
+
options={{
|
|
242
|
+
headerTransparent: true,
|
|
243
|
+
headerBackground: () => (
|
|
244
|
+
<BlurView
|
|
245
|
+
tint="light"
|
|
246
|
+
intensity={100}
|
|
247
|
+
style={StyleSheet.absoluteFill}
|
|
248
|
+
/>
|
|
249
|
+
),
|
|
250
|
+
}}
|
|
251
|
+
/>
|
|
252
|
+
</Tab.Navigator>
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
- `headerStyle` does not apply when `headerBackground` is used. Style the element returned from `headerBackground` instead.
|
|
258
|
+
- Transparent headers overlap the content below. Add top spacing manually using `useHeaderHeight` hook from `@react-navigation/elements`
|
|
259
|
+
|
|
260
|
+
## Canonical Docs
|
|
261
|
+
|
|
262
|
+
- [Configuring the header bar](https://reactnavigation.org/docs/headers)
|
|
263
|
+
- [Bottom Tabs Navigator](https://reactnavigation.org/docs/bottom-tab-navigator)
|
|
264
|
+
- [Drawer Navigator](https://reactnavigation.org/docs/drawer-navigator)
|
|
265
|
+
|
|
266
|
+
## Related Skills
|
|
267
|
+
|
|
268
|
+
- [bottom-tabs.md](./bottom-tabs.md)
|
|
269
|
+
- [drawers.md](./drawers.md)
|
|
270
|
+
- [stacks.md](./stacks.md)
|