agentic-mobile-kit 0.0.2 → 0.2.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/e2e.yml +72 -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 +46 -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 +14 -0
- package/stacks/react-native/template/scripts/ai/pm-run.sh +16 -0
- package/stacks/react-native/template/scripts/ai/verify.sh +139 -0
- package/stacks/react-native/template/specs/_templates/design.md +15 -0
- package/stacks/react-native/template/specs/_templates/flow.yaml +14 -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,365 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Native Bottom Tabs
|
|
3
|
+
impact: HIGH
|
|
4
|
+
tags: react-navigation, native-bottom-tabs, native-stack, navigate, search-tab, bottom-accessory, sidebar
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Skill: Native Bottom Tabs
|
|
8
|
+
|
|
9
|
+
## Description
|
|
10
|
+
|
|
11
|
+
Use `createNativeBottomTabNavigator` for a native tab bar on iOS and Android.
|
|
12
|
+
|
|
13
|
+
Conditionally use [bottom-tabs.md](./bottom-tabs.md) if web support is needed.
|
|
14
|
+
|
|
15
|
+
## When to Use
|
|
16
|
+
|
|
17
|
+
- Building primary app destinations behind a tab bar
|
|
18
|
+
- The app runs on iOS or Android
|
|
19
|
+
|
|
20
|
+
## Basic Example
|
|
21
|
+
|
|
22
|
+
**Static API**
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import { createNativeBottomTabNavigator } from '@react-navigation/bottom-tabs/unstable';
|
|
26
|
+
|
|
27
|
+
const AppTabs = createNativeBottomTabNavigator({
|
|
28
|
+
screens: {
|
|
29
|
+
Home: HomeScreen,
|
|
30
|
+
Profile: ProfileScreen,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Dynamic API**
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
import { createNativeBottomTabNavigator } from '@react-navigation/bottom-tabs/unstable';
|
|
39
|
+
|
|
40
|
+
const Tab = createNativeBottomTabNavigator();
|
|
41
|
+
|
|
42
|
+
function AppTabs() {
|
|
43
|
+
return (
|
|
44
|
+
<Tab.Navigator>
|
|
45
|
+
<Tab.Screen name="Home" component={HomeScreen} />
|
|
46
|
+
<Tab.Screen name="Profile" component={ProfileScreen} />
|
|
47
|
+
</Tab.Navigator>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Avoiding Overlap with the Tab Bar
|
|
53
|
+
|
|
54
|
+
On iOS, content inset is automatically adjusted for scrollable views to avoid overlap with the tab bar.
|
|
55
|
+
|
|
56
|
+
For non-scrollable content, or on Android, use the experimental `SafeAreaView` from `react-native-screens/experimental` to apply padding for the tab bar.
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
import { SafeAreaView } from 'react-native-screens/experimental';
|
|
60
|
+
|
|
61
|
+
function ProfileScreen() {
|
|
62
|
+
return <SafeAreaView edges={{ bottom: true }}>{/* content */}</SafeAreaView>;
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Common Features
|
|
67
|
+
|
|
68
|
+
### Displaying Icons
|
|
69
|
+
|
|
70
|
+
Use `tabBarIcon` in `screenOptions` or per-screen `options`. Optionally use `tabBarActiveTintColor` and `tabBarInactiveTintColor` to change the color of the icon (support varies based on platform).
|
|
71
|
+
|
|
72
|
+
**Static API**
|
|
73
|
+
|
|
74
|
+
```tsx
|
|
75
|
+
const AppTabs = createNativeBottomTabNavigator({
|
|
76
|
+
screens: {
|
|
77
|
+
Feed: {
|
|
78
|
+
screen: FeedScreen,
|
|
79
|
+
options: {
|
|
80
|
+
tabBarIcon: Platform.select({
|
|
81
|
+
ios: {
|
|
82
|
+
type: 'sfSymbol',
|
|
83
|
+
name: 'favorites',
|
|
84
|
+
},
|
|
85
|
+
default: {
|
|
86
|
+
type: 'image',
|
|
87
|
+
source: require('./assets/feed.png'),
|
|
88
|
+
},
|
|
89
|
+
}),
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Dynamic API**
|
|
97
|
+
|
|
98
|
+
```tsx
|
|
99
|
+
const Tab = createNativeBottomTabNavigator();
|
|
100
|
+
|
|
101
|
+
function AppTabs() {
|
|
102
|
+
return (
|
|
103
|
+
<Tab.Navigator>
|
|
104
|
+
<Tab.Screen
|
|
105
|
+
name="Feed"
|
|
106
|
+
component={FeedScreen}
|
|
107
|
+
options={{
|
|
108
|
+
tabBarIcon: Platform.select({
|
|
109
|
+
ios: {
|
|
110
|
+
type: 'sfSymbol',
|
|
111
|
+
name: 'favorites',
|
|
112
|
+
},
|
|
113
|
+
default: {
|
|
114
|
+
type: 'image',
|
|
115
|
+
source: require('./assets/feed.png'),
|
|
116
|
+
},
|
|
117
|
+
}),
|
|
118
|
+
}}
|
|
119
|
+
/>
|
|
120
|
+
</Tab.Navigator>
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
The `tabBarIcon` option supports multiple types of icons:
|
|
126
|
+
|
|
127
|
+
- SF Symbols on iOS with `type: 'sfSymbol'` and `name`.
|
|
128
|
+
- Local images with `type: 'image'` and `source`.
|
|
129
|
+
|
|
130
|
+
Prefer SF Symbols on iOS, and image icons for other platforms. Use `Platform.select` to specify different icons per platform if needed.
|
|
131
|
+
|
|
132
|
+
When using image icons:
|
|
133
|
+
|
|
134
|
+
- Provide `1x`, `2x`, and `3x` image assets (`image.png`, `image@2x.png`, `image@3x.png`) because iOS does not scale tab icons automatically.
|
|
135
|
+
- Set `tinted: false` on iOS (`{ type: 'image', tinted: false, source: require('./assets/feed.png') }`) if the image should keep its original colors. Android always tints image icons.
|
|
136
|
+
|
|
137
|
+
### Search Tab on iOS 26+
|
|
138
|
+
|
|
139
|
+
Use the built-in `search` system item together with a nested native stack navigator whose focused screen defines `headerSearchBarOptions`.
|
|
140
|
+
|
|
141
|
+
**Static API**
|
|
142
|
+
|
|
143
|
+
```tsx
|
|
144
|
+
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
|
145
|
+
|
|
146
|
+
const SearchStack = createNativeStackNavigator({
|
|
147
|
+
screens: {
|
|
148
|
+
FruitsList: {
|
|
149
|
+
screen: FruitsListScreen,
|
|
150
|
+
options: {
|
|
151
|
+
title: 'Search',
|
|
152
|
+
headerSearchBarOptions: {
|
|
153
|
+
placeholder: 'Search fruits',
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
const AppTabs = createNativeBottomTabNavigator({
|
|
161
|
+
screens: {
|
|
162
|
+
Search: {
|
|
163
|
+
screen: SearchStack,
|
|
164
|
+
options: {
|
|
165
|
+
tabBarSystemItem: 'search',
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
**Dynamic API**
|
|
173
|
+
|
|
174
|
+
```tsx
|
|
175
|
+
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
|
176
|
+
|
|
177
|
+
const Stack = createNativeStackNavigator();
|
|
178
|
+
const Tab = createNativeBottomTabNavigator();
|
|
179
|
+
|
|
180
|
+
function SearchStack() {
|
|
181
|
+
return (
|
|
182
|
+
<Stack.Navigator>
|
|
183
|
+
<Stack.Screen
|
|
184
|
+
name="FruitsList"
|
|
185
|
+
component={FruitsListScreen}
|
|
186
|
+
options={{
|
|
187
|
+
title: 'Search',
|
|
188
|
+
headerSearchBarOptions: {
|
|
189
|
+
placeholder: 'Search fruits',
|
|
190
|
+
},
|
|
191
|
+
}}
|
|
192
|
+
/>
|
|
193
|
+
</Stack.Navigator>
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function AppTabs() {
|
|
198
|
+
return (
|
|
199
|
+
<Tab.Navigator>
|
|
200
|
+
<Tab.Screen
|
|
201
|
+
name="Search"
|
|
202
|
+
component={SearchStack}
|
|
203
|
+
options={{
|
|
204
|
+
tabBarSystemItem: 'search',
|
|
205
|
+
}}
|
|
206
|
+
/>
|
|
207
|
+
</Tab.Navigator>
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
- This behavior is available on iOS 26 and above.
|
|
213
|
+
- The tab bar transforms into a search field only when the selected tab renders a nested native stack navigator.
|
|
214
|
+
- The focused screen in that nested native stack must define `headerSearchBarOptions`.
|
|
215
|
+
|
|
216
|
+
### Bottom Accessory
|
|
217
|
+
|
|
218
|
+
Use `bottomAccessory` to render content above the tab bar or inline with the collapsed bar.
|
|
219
|
+
|
|
220
|
+
**Static API**
|
|
221
|
+
|
|
222
|
+
```tsx
|
|
223
|
+
const AppTabs = createNativeBottomTabNavigator({
|
|
224
|
+
screenOptions: {
|
|
225
|
+
bottomAccessory: ({ placement }) => {
|
|
226
|
+
return (
|
|
227
|
+
<View style={{ padding: 16 }}>
|
|
228
|
+
<Text>Placement: {placement}</Text>
|
|
229
|
+
</View>
|
|
230
|
+
);
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
screens: {
|
|
234
|
+
Home: HomeScreen,
|
|
235
|
+
},
|
|
236
|
+
});
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
**Dynamic API**
|
|
240
|
+
|
|
241
|
+
```tsx
|
|
242
|
+
const Tab = createNativeBottomTabNavigator();
|
|
243
|
+
|
|
244
|
+
function AppTabs() {
|
|
245
|
+
return (
|
|
246
|
+
<Tab.Navigator
|
|
247
|
+
screenOptions={{
|
|
248
|
+
bottomAccessory: ({ placement }) => {
|
|
249
|
+
return (
|
|
250
|
+
<View style={{ padding: 16 }}>
|
|
251
|
+
<Text>Placement: {placement}</Text>
|
|
252
|
+
</View>
|
|
253
|
+
);
|
|
254
|
+
},
|
|
255
|
+
}}
|
|
256
|
+
>
|
|
257
|
+
<Tab.Screen name="Home" component={HomeScreen} />
|
|
258
|
+
</Tab.Navigator>
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
- `placement` is `regular` above the bar or `inline` when the bar is collapsed.
|
|
264
|
+
- This is supported on iOS 26 and above.
|
|
265
|
+
- The accessory renders twice, once per placement, so shared state should live outside the returned component.
|
|
266
|
+
|
|
267
|
+
### Sidebar
|
|
268
|
+
|
|
269
|
+
Use `tabBarControllerMode: 'tabSidebar'` to display the native tab controller as a sidebar.
|
|
270
|
+
|
|
271
|
+
**Static API**
|
|
272
|
+
|
|
273
|
+
```tsx
|
|
274
|
+
const AppTabs = createNativeBottomTabNavigator({
|
|
275
|
+
screenOptions: {
|
|
276
|
+
tabBarControllerMode: 'tabSidebar',
|
|
277
|
+
},
|
|
278
|
+
screens: {
|
|
279
|
+
Home: HomeScreen,
|
|
280
|
+
Search: SearchScreen,
|
|
281
|
+
},
|
|
282
|
+
});
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
**Dynamic API**
|
|
286
|
+
|
|
287
|
+
```tsx
|
|
288
|
+
const Tab = createNativeBottomTabNavigator();
|
|
289
|
+
|
|
290
|
+
function AppTabs() {
|
|
291
|
+
return (
|
|
292
|
+
<Tab.Navigator
|
|
293
|
+
screenOptions={{
|
|
294
|
+
tabBarControllerMode: 'tabSidebar',
|
|
295
|
+
}}
|
|
296
|
+
>
|
|
297
|
+
<Tab.Screen name="Home" component={HomeScreen} />
|
|
298
|
+
<Tab.Screen name="Search" component={SearchScreen} />
|
|
299
|
+
</Tab.Navigator>
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
- `auto` lets the system choose the presentation.
|
|
305
|
+
- `tabBar` forces the standard tab bar.
|
|
306
|
+
- Sidebar mode is supported on iOS 18 and above and not on tvOS.
|
|
307
|
+
|
|
308
|
+
### Minimize on Scroll
|
|
309
|
+
|
|
310
|
+
Use `tabBarMinimizeBehavior` to let the system collapse the tab bar while scrolling.
|
|
311
|
+
|
|
312
|
+
**Static API**
|
|
313
|
+
|
|
314
|
+
```tsx
|
|
315
|
+
const AppTabs = createNativeBottomTabNavigator({
|
|
316
|
+
screenOptions: {
|
|
317
|
+
tabBarMinimizeBehavior: 'onScrollDown',
|
|
318
|
+
},
|
|
319
|
+
screens: {
|
|
320
|
+
Home: HomeScreen,
|
|
321
|
+
},
|
|
322
|
+
});
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
**Dynamic API**
|
|
326
|
+
|
|
327
|
+
```tsx
|
|
328
|
+
const Tab = createNativeBottomTabNavigator();
|
|
329
|
+
|
|
330
|
+
function AppTabs() {
|
|
331
|
+
return (
|
|
332
|
+
<Tab.Navigator
|
|
333
|
+
screenOptions={{
|
|
334
|
+
tabBarMinimizeBehavior: 'onScrollDown',
|
|
335
|
+
}}
|
|
336
|
+
>
|
|
337
|
+
<Tab.Screen name="Home" component={HomeScreen} />
|
|
338
|
+
</Tab.Navigator>
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
- Supported values are `auto`, `never`, `onScrollDown`, and `onScrollUp`.
|
|
344
|
+
- This is supported on iOS 26 and above.
|
|
345
|
+
|
|
346
|
+
## Notes
|
|
347
|
+
|
|
348
|
+
- React Native 0.79 or above is required. If you're using Expo, SDK 53 or above is required.
|
|
349
|
+
- The app must use the latest `react-native-screens` along with the latest version of `@react-navigation/bottom-tabs` to avoid compatibility issues.
|
|
350
|
+
- When using Expo, development builds maybe required to support the latest version of `react-native-screens`.
|
|
351
|
+
- Liquid Glass effect on iOS 26+ requires your app to be built with Xcode 26 or above.
|
|
352
|
+
- On Android, at most 5 tabs are supported. This is a limitation of the underlying native component.
|
|
353
|
+
- No header is shown by default. A basic JS based header can be shown with `headerShown: true` option (see [header.md](./header.md)), or a native header can be shown by nesting a native stack navigator inside each tab screen.
|
|
354
|
+
|
|
355
|
+
## Canonical Docs
|
|
356
|
+
|
|
357
|
+
- [Native Bottom Tabs Navigator](https://reactnavigation.org/docs/native-bottom-tab-navigator)
|
|
358
|
+
- [Native Stack Navigator](https://reactnavigation.org/docs/native-stack-navigator)
|
|
359
|
+
|
|
360
|
+
## Related Skills
|
|
361
|
+
|
|
362
|
+
- [bottom-tabs.md](./bottom-tabs.md)
|
|
363
|
+
- [stacks.md](./stacks.md)
|
|
364
|
+
- [safe-areas.md](./safe-areas.md)
|
|
365
|
+
- [header.md](./header.md)
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Safe Areas
|
|
3
|
+
impact: HIGH
|
|
4
|
+
tags: react-navigation, safe-area, inset, safe-area-context, scroll-view, flatlist, edge-to-edge
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Skill: Safe Areas
|
|
8
|
+
|
|
9
|
+
## Description
|
|
10
|
+
|
|
11
|
+
Use this reference when content or scroll containers must avoid notches, system bars, home indicators, and other system UI.
|
|
12
|
+
|
|
13
|
+
React Navigation already handles safe areas for its built-in UI such as headers, tab bars, and drawers. Apply insets manually only for your own screen content or when you replace the built-in navigation UI with custom components.
|
|
14
|
+
|
|
15
|
+
## When to Use
|
|
16
|
+
|
|
17
|
+
- Content is hidden behind the status bar, navigation bar, notch, or home indicator
|
|
18
|
+
- A screen uses a custom header, custom tab bar, or custom drawer content
|
|
19
|
+
- Fixed UI such as hero media, floating actions, or bottom actions needs selective safe-area padding
|
|
20
|
+
|
|
21
|
+
## Edge-to-Edge on Android
|
|
22
|
+
|
|
23
|
+
Edge-to-edge makes the app content extend behind translucent system bars on Android, similar to how it works on iOS. Enable edge-to-edge for consistent safe area handling across platforms.
|
|
24
|
+
|
|
25
|
+
Android enables edge-to-edge by default from Android 15 (API level 35) for apps targeting API level 35. Edge-to-edge cannot be disabled from Android 16 (API level 36). For older Android versions, edge-to-edge can be enabled from React Native 0.81 onwards in `android/gradle.properties`:
|
|
26
|
+
|
|
27
|
+
```ini
|
|
28
|
+
edgeToEdgeEnabled=true
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Using `contentInsetAdjustmentBehavior` for `ScrollView`
|
|
32
|
+
|
|
33
|
+
When the main screen content scrolls (such as a `ScrollView`, `FlatList`, `SectionList` etc.) on iOS, prefer `contentInsetAdjustmentBehavior="automatic"` so the scroll view adjusts for safe areas while still allowing edge-to-edge scrolling behavior.
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import { ScrollView } from 'react-native';
|
|
37
|
+
|
|
38
|
+
function ArticleScreen() {
|
|
39
|
+
return (
|
|
40
|
+
<ScrollView contentInsetAdjustmentBehavior="automatic">
|
|
41
|
+
{/* content */}
|
|
42
|
+
</ScrollView>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
On Android, conditionally use the `useSafeAreaInsets` hook from `react-native-safe-area-context` to apply paddings.
|
|
48
|
+
|
|
49
|
+
## Using `useSafeAreaInsets`
|
|
50
|
+
|
|
51
|
+
Use the `useSafeAreaInsets` hook from `react-native-safe-area-context` for custom layouts. It gives precise control over which edges should receive padding.
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
import { View } from 'react-native';
|
|
55
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
56
|
+
|
|
57
|
+
function ScreenContent() {
|
|
58
|
+
const insets = useSafeAreaInsets();
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<View
|
|
62
|
+
style={{
|
|
63
|
+
flex: 1,
|
|
64
|
+
paddingTop: insets.top,
|
|
65
|
+
paddingBottom: insets.bottom,
|
|
66
|
+
paddingLeft: insets.left,
|
|
67
|
+
paddingRight: insets.right,
|
|
68
|
+
}}
|
|
69
|
+
>
|
|
70
|
+
{/* content */}
|
|
71
|
+
</View>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
- Prefer the hook over `SafeAreaView`, as `SafeAreaView` can behave poorly during animations, and mixing `SafeAreaView` with the hook can cause flicker.
|
|
77
|
+
- It is usually not necessary to wrap the app in `SafeAreaProvider` as it's done internally by React Navigation. Only add it when using in components not in stack, bottom tabs or drawer navigators.
|
|
78
|
+
- Apply insets to only the specific edges that extend to the screen edge
|
|
79
|
+
- Keep landscape orientation in mind, as the top and bottom insets become left and right insets
|
|
80
|
+
- Do not wrap the whole app in a `SafeAreaView` to avoid wasting space.
|
|
81
|
+
|
|
82
|
+
## Canonical Docs
|
|
83
|
+
|
|
84
|
+
- [React Navigation: Supporting safe areas](https://reactnavigation.org/docs/handling-safe-area/)
|
|
85
|
+
- [React Native: ScrollView](https://reactnative.dev/docs/scrollview)
|
|
86
|
+
- [React Navigation: Native Stack Navigator](https://reactnavigation.org/docs/native-stack-navigator)
|
|
87
|
+
- [React Native 0.81: Android 16 support and edge-to-edge](https://reactnative.dev/blog/2025/08/12/react-native-0.81)
|
|
88
|
+
- [react-native-safe-area-context](https://github.com/AppAndFlow/react-native-safe-area-context)
|
|
89
|
+
|
|
90
|
+
## Related Skills
|
|
91
|
+
|
|
92
|
+
- [stacks.md](./stacks.md)
|
|
93
|
+
- [bottom-tabs.md](./bottom-tabs.md)
|
|
94
|
+
- [native-bottom-tabs.md](./native-bottom-tabs.md)
|
|
95
|
+
- [drawers.md](./drawers.md)
|