agentic-mobile-kit 0.0.1 → 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 +17 -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
package/stacks/react-native/template/.agents/skills/react-navigation/references/bottom-tabs.md
ADDED
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Bottom Tabs
|
|
3
|
+
impact: HIGH
|
|
4
|
+
tags: react-navigation, bottom-tabs, tab-bar, icons, blur, sidebar, header
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Skill: Bottom Tabs
|
|
8
|
+
|
|
9
|
+
## Description
|
|
10
|
+
|
|
11
|
+
Use `createBottomTabNavigator` for cross-platform tab navigation with a tab bar that can stay at the bottom on smaller screens and move to the side on larger layouts if the app needs web support.
|
|
12
|
+
|
|
13
|
+
Conditionally use [native-bottom-tabs.md](./native-bottom-tabs.md) on Android and iOS for a native tab bar.
|
|
14
|
+
|
|
15
|
+
## When to Use
|
|
16
|
+
|
|
17
|
+
- Building primary app destinations behind a tab bar
|
|
18
|
+
- The app needs to run on web and mobile
|
|
19
|
+
|
|
20
|
+
## Basic Example
|
|
21
|
+
|
|
22
|
+
**Static API**
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
|
26
|
+
|
|
27
|
+
const AppTabs = createBottomTabNavigator({
|
|
28
|
+
screens: {
|
|
29
|
+
Home: HomeScreen,
|
|
30
|
+
Profile: ProfileScreen,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Dynamic API**
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
|
39
|
+
|
|
40
|
+
const Tab = createBottomTabNavigator();
|
|
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
|
+
## Common Features
|
|
53
|
+
|
|
54
|
+
### Displaying Icons
|
|
55
|
+
|
|
56
|
+
Use `tabBarIcon` in `screenOptions` or per-screen `options`. Optionally use `tabBarActiveTintColor` and `tabBarInactiveTintColor` to change the color passed to the icon.
|
|
57
|
+
|
|
58
|
+
**Static API**
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
import Ionicons from '@expo/vector-icons/Ionicons';
|
|
62
|
+
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
|
63
|
+
|
|
64
|
+
const AppTabs = createBottomTabNavigator({
|
|
65
|
+
screenOptions: ({ route }) => ({
|
|
66
|
+
tabBarIcon: ({ focused, color, size }) => {
|
|
67
|
+
let iconName;
|
|
68
|
+
|
|
69
|
+
switch (route.name) {
|
|
70
|
+
case 'Home':
|
|
71
|
+
iconName = focused ? 'home' : 'home-outline';
|
|
72
|
+
break;
|
|
73
|
+
default:
|
|
74
|
+
iconName = focused ? 'settings' : 'settings-outline';
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return <Ionicons name={iconName} size={size} color={color} />;
|
|
79
|
+
},
|
|
80
|
+
tabBarActiveTintColor: 'tomato',
|
|
81
|
+
tabBarInactiveTintColor: 'gray',
|
|
82
|
+
}),
|
|
83
|
+
screens: {
|
|
84
|
+
Home: HomeScreen,
|
|
85
|
+
Settings: SettingsScreen,
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Dynamic API**
|
|
91
|
+
|
|
92
|
+
```tsx
|
|
93
|
+
import Ionicons from '@expo/vector-icons/Ionicons';
|
|
94
|
+
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
|
95
|
+
|
|
96
|
+
const Tab = createBottomTabNavigator();
|
|
97
|
+
|
|
98
|
+
function AppTabs() {
|
|
99
|
+
return (
|
|
100
|
+
<Tab.Navigator
|
|
101
|
+
screenOptions={({ route }) => ({
|
|
102
|
+
tabBarIcon: ({ focused, color, size }) => {
|
|
103
|
+
let iconName;
|
|
104
|
+
|
|
105
|
+
switch (route.name) {
|
|
106
|
+
case 'Home':
|
|
107
|
+
iconName = focused ? 'home' : 'home-outline';
|
|
108
|
+
break;
|
|
109
|
+
default:
|
|
110
|
+
iconName = focused ? 'settings' : 'settings-outline';
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return <Ionicons name={iconName} size={size} color={color} />;
|
|
115
|
+
},
|
|
116
|
+
tabBarActiveTintColor: 'tomato',
|
|
117
|
+
tabBarInactiveTintColor: 'gray',
|
|
118
|
+
})}
|
|
119
|
+
>
|
|
120
|
+
<Tab.Screen name="Home" component={HomeScreen} />
|
|
121
|
+
<Tab.Screen name="Settings" component={SettingsScreen} />
|
|
122
|
+
</Tab.Navigator>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
The `tabBarIcon` option can render any React element. Choose between the icon libraries that best fit the app's design and environment:
|
|
128
|
+
|
|
129
|
+
- `@expo/vector-icons` if Expo SDK is configured in the app
|
|
130
|
+
- `react-native-vector-icons` for an app using React Native Community CLI
|
|
131
|
+
- `<Image>` for local images
|
|
132
|
+
|
|
133
|
+
### Scroll to Top on Tab Press
|
|
134
|
+
|
|
135
|
+
Use `useScrollToTop` on a scrollable ref inside a screen in the tab navigator to automatically scroll to the top when the tab is pressed while already focused.
|
|
136
|
+
|
|
137
|
+
```tsx
|
|
138
|
+
import * as React from 'react';
|
|
139
|
+
import { ScrollView } from 'react-native';
|
|
140
|
+
import { useScrollToTop } from '@react-navigation/native';
|
|
141
|
+
|
|
142
|
+
function FeedScreen() {
|
|
143
|
+
const ref = React.useRef(null);
|
|
144
|
+
|
|
145
|
+
useScrollToTop(ref);
|
|
146
|
+
|
|
147
|
+
return <ScrollView ref={ref}>{/* content */}</ScrollView>;
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Custom Background Such as Blur
|
|
152
|
+
|
|
153
|
+
Use `tabBarBackground` for custom chrome such as blur effects, image, or gradient backgrounds. When the background should show through the tab bar, set `tabBarStyle: { position: 'absolute' }` and use `useBottomTabBarHeight` inside the screens to pad the content.
|
|
154
|
+
|
|
155
|
+
**Static API**
|
|
156
|
+
|
|
157
|
+
```tsx
|
|
158
|
+
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
|
159
|
+
import { BlurView } from 'expo-blur';
|
|
160
|
+
import { StyleSheet } from 'react-native';
|
|
161
|
+
|
|
162
|
+
const AppTabs = createBottomTabNavigator({
|
|
163
|
+
screenOptions: {
|
|
164
|
+
tabBarStyle: { position: 'absolute' },
|
|
165
|
+
tabBarBackground: () => (
|
|
166
|
+
<BlurView tint="light" intensity={100} style={StyleSheet.absoluteFill} />
|
|
167
|
+
),
|
|
168
|
+
},
|
|
169
|
+
screens: {
|
|
170
|
+
Home: HomeScreen,
|
|
171
|
+
Profile: ProfileScreen,
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Dynamic API**
|
|
177
|
+
|
|
178
|
+
```tsx
|
|
179
|
+
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
|
180
|
+
import { BlurView } from 'expo-blur';
|
|
181
|
+
import { StyleSheet } from 'react-native';
|
|
182
|
+
|
|
183
|
+
const Tab = createBottomTabNavigator();
|
|
184
|
+
|
|
185
|
+
function AppTabs() {
|
|
186
|
+
return (
|
|
187
|
+
<Tab.Navigator
|
|
188
|
+
screenOptions={{
|
|
189
|
+
tabBarStyle: { position: 'absolute' },
|
|
190
|
+
tabBarBackground: () => (
|
|
191
|
+
<BlurView
|
|
192
|
+
tint="light"
|
|
193
|
+
intensity={100}
|
|
194
|
+
style={StyleSheet.absoluteFill}
|
|
195
|
+
/>
|
|
196
|
+
),
|
|
197
|
+
}}
|
|
198
|
+
>
|
|
199
|
+
<Tab.Screen name="Home" component={HomeScreen} />
|
|
200
|
+
<Tab.Screen name="Profile" component={ProfileScreen} />
|
|
201
|
+
</Tab.Navigator>
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Custom Tab Bar
|
|
207
|
+
|
|
208
|
+
Use the `tabBar` option if a custom design is needed. Use the `state` prop to access the list of screens and `descriptors` to access the options for each screen. Use the `navigation` prop passed to the tab bar for navigation instead of `useNavigation`.
|
|
209
|
+
|
|
210
|
+
```tsx
|
|
211
|
+
import { Text, View } from 'react-native';
|
|
212
|
+
import { useLinkBuilder } from '@react-navigation/native';
|
|
213
|
+
import { PlatformPressable } from '@react-navigation/elements';
|
|
214
|
+
|
|
215
|
+
function MyTabBar({ state, descriptors, navigation }) {
|
|
216
|
+
const { buildHref } = useLinkBuilder();
|
|
217
|
+
|
|
218
|
+
return (
|
|
219
|
+
<View style={{ flexDirection: 'row' }}>
|
|
220
|
+
{state.routes.map((route, index) => {
|
|
221
|
+
const { options } = descriptors[route.key];
|
|
222
|
+
const label =
|
|
223
|
+
options.tabBarLabel !== undefined
|
|
224
|
+
? options.tabBarLabel
|
|
225
|
+
: options.title !== undefined
|
|
226
|
+
? options.title
|
|
227
|
+
: route.name;
|
|
228
|
+
|
|
229
|
+
const isFocused = state.index === index;
|
|
230
|
+
|
|
231
|
+
return (
|
|
232
|
+
<PlatformPressable
|
|
233
|
+
key={route.key}
|
|
234
|
+
href={buildHref(route.name, route.params)}
|
|
235
|
+
onPress={() => {
|
|
236
|
+
const event = navigation.emit({
|
|
237
|
+
type: 'tabPress',
|
|
238
|
+
target: route.key,
|
|
239
|
+
canPreventDefault: true,
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
if (!isFocused && !event.defaultPrevented) {
|
|
243
|
+
navigation.navigate(route.name, route.params);
|
|
244
|
+
}
|
|
245
|
+
}}
|
|
246
|
+
onLongPress={() =>
|
|
247
|
+
navigation.emit({
|
|
248
|
+
type: 'tabLongPress',
|
|
249
|
+
target: route.key,
|
|
250
|
+
})
|
|
251
|
+
}
|
|
252
|
+
style={{ flex: 1, alignItems: 'center', paddingVertical: 12 }}
|
|
253
|
+
>
|
|
254
|
+
<Text style={{ opacity: isFocused ? 1 : 0.6 }}>{label}</Text>
|
|
255
|
+
</PlatformPressable>
|
|
256
|
+
);
|
|
257
|
+
})}
|
|
258
|
+
</View>
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
**Static API**
|
|
264
|
+
|
|
265
|
+
```tsx
|
|
266
|
+
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
|
267
|
+
|
|
268
|
+
const AppTabs = createBottomTabNavigator({
|
|
269
|
+
tabBar: (props) => <MyTabBar {...props} />,
|
|
270
|
+
screens: {
|
|
271
|
+
Home: HomeScreen,
|
|
272
|
+
Profile: ProfileScreen,
|
|
273
|
+
},
|
|
274
|
+
});
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
**Dynamic API**
|
|
278
|
+
|
|
279
|
+
```tsx
|
|
280
|
+
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
|
281
|
+
|
|
282
|
+
const Tab = createBottomTabNavigator();
|
|
283
|
+
|
|
284
|
+
function AppTabs() {
|
|
285
|
+
return (
|
|
286
|
+
<Tab.Navigator tabBar={(props) => <MyTabBar {...props} />}>
|
|
287
|
+
<Tab.Screen name="Home" component={HomeScreen} />
|
|
288
|
+
<Tab.Screen name="Profile" component={ProfileScreen} />
|
|
289
|
+
</Tab.Navigator>
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### Sidebar
|
|
295
|
+
|
|
296
|
+
Set `tabBarPosition` to `left` or `right` to render the tab bar as a sidebar. Choose the position based on the screen width for responsive layouts.
|
|
297
|
+
|
|
298
|
+
**Static API**
|
|
299
|
+
|
|
300
|
+
```tsx
|
|
301
|
+
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
|
302
|
+
|
|
303
|
+
const AppTabs = createBottomTabNavigator({
|
|
304
|
+
screenOptions: {
|
|
305
|
+
tabBarPosition: 'left',
|
|
306
|
+
},
|
|
307
|
+
screens: {
|
|
308
|
+
Home: HomeScreen,
|
|
309
|
+
Profile: ProfileScreen,
|
|
310
|
+
},
|
|
311
|
+
}).with(({ Navigator }) => {
|
|
312
|
+
const dimensions = useWindowDimensions();
|
|
313
|
+
|
|
314
|
+
return (
|
|
315
|
+
<Navigator
|
|
316
|
+
screenOptions={{
|
|
317
|
+
tabBarPosition: dimensions.width >= 768 ? 'left' : 'bottom',
|
|
318
|
+
}}
|
|
319
|
+
/>
|
|
320
|
+
);
|
|
321
|
+
});
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
**Dynamic API**
|
|
325
|
+
|
|
326
|
+
```tsx
|
|
327
|
+
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
|
328
|
+
import { useWindowDimensions } from 'react-native';
|
|
329
|
+
|
|
330
|
+
const Tab = createBottomTabNavigator();
|
|
331
|
+
|
|
332
|
+
function AppTabs() {
|
|
333
|
+
const dimensions = useWindowDimensions();
|
|
334
|
+
|
|
335
|
+
return (
|
|
336
|
+
<Tab.Navigator
|
|
337
|
+
screenOptions={{
|
|
338
|
+
tabBarPosition: dimensions.width >= 768 ? 'left' : 'bottom',
|
|
339
|
+
}}
|
|
340
|
+
>
|
|
341
|
+
<Tab.Screen name="Home" component={HomeScreen} />
|
|
342
|
+
<Tab.Screen name="Profile" component={ProfileScreen} />
|
|
343
|
+
</Tab.Navigator>
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
For a compact sidebar, use `tabBarVariant: 'material'` together with `tabBarLabelPosition: 'below-icon'`.
|
|
349
|
+
|
|
350
|
+
### Customizing Header
|
|
351
|
+
|
|
352
|
+
Bottom tabs show a header by default. Use [header.md](./header.md) for common customization patterns.
|
|
353
|
+
|
|
354
|
+
A custom header can be shown with the `header` option if a custom design is needed.
|
|
355
|
+
|
|
356
|
+
**Static API**
|
|
357
|
+
|
|
358
|
+
```tsx
|
|
359
|
+
import { getHeaderTitle } from '@react-navigation/elements';
|
|
360
|
+
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
|
361
|
+
|
|
362
|
+
const AppTabs = createBottomTabNavigator({
|
|
363
|
+
screens: {
|
|
364
|
+
Home: {
|
|
365
|
+
screen: HomeScreen,
|
|
366
|
+
options: {
|
|
367
|
+
headerStyle: {
|
|
368
|
+
height: 80,
|
|
369
|
+
},
|
|
370
|
+
header: ({ route, options }) => {
|
|
371
|
+
const title = getHeaderTitle(options, route.name);
|
|
372
|
+
|
|
373
|
+
return <MyHeader title={title} style={options.headerStyle} />;
|
|
374
|
+
},
|
|
375
|
+
},
|
|
376
|
+
},
|
|
377
|
+
},
|
|
378
|
+
});
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
**Dynamic API**
|
|
382
|
+
|
|
383
|
+
```tsx
|
|
384
|
+
import { getHeaderTitle } from '@react-navigation/elements';
|
|
385
|
+
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
|
386
|
+
|
|
387
|
+
const Tab = createBottomTabNavigator();
|
|
388
|
+
|
|
389
|
+
function AppTabs() {
|
|
390
|
+
return (
|
|
391
|
+
<Tab.Navigator>
|
|
392
|
+
<Tab.Screen
|
|
393
|
+
name="Home"
|
|
394
|
+
component={HomeScreen}
|
|
395
|
+
options={{
|
|
396
|
+
headerStyle: {
|
|
397
|
+
height: 80,
|
|
398
|
+
},
|
|
399
|
+
header: ({ route, options }) => {
|
|
400
|
+
const title = getHeaderTitle(options, route.name);
|
|
401
|
+
|
|
402
|
+
return <MyHeader title={title} style={options.headerStyle} />;
|
|
403
|
+
},
|
|
404
|
+
}}
|
|
405
|
+
/>
|
|
406
|
+
</Tab.Navigator>
|
|
407
|
+
);
|
|
408
|
+
}
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
- Set `headerShown: false` to hide the header.
|
|
412
|
+
- If a custom header uses a non-default height, set `headerStyle: { height: ... }` explicitly to avoid measurement glitches.
|
|
413
|
+
|
|
414
|
+
## Hiding Tab Bar on Certain Screens
|
|
415
|
+
|
|
416
|
+
The tab bar is shown on all screens in the tab navigator. To hide the tab bar on certain screens, put those screens in a parent stack navigator instead.
|
|
417
|
+
|
|
418
|
+
**Static API**
|
|
419
|
+
|
|
420
|
+
```tsx
|
|
421
|
+
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
|
422
|
+
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
|
423
|
+
|
|
424
|
+
const HomeTabs = createBottomTabNavigator({
|
|
425
|
+
screens: {
|
|
426
|
+
Home: HomeScreen,
|
|
427
|
+
Feed: FeedScreen,
|
|
428
|
+
Notifications: NotificationsScreen,
|
|
429
|
+
},
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
const AppStack = createNativeStackNavigator({
|
|
433
|
+
screens: {
|
|
434
|
+
Main: {
|
|
435
|
+
screen: HomeTabs,
|
|
436
|
+
options: {
|
|
437
|
+
headerShown: false,
|
|
438
|
+
},
|
|
439
|
+
},
|
|
440
|
+
Profile: ProfileScreen,
|
|
441
|
+
Settings: SettingsScreen,
|
|
442
|
+
},
|
|
443
|
+
});
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
**Dynamic API**
|
|
447
|
+
|
|
448
|
+
```tsx
|
|
449
|
+
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
|
450
|
+
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
|
451
|
+
|
|
452
|
+
const Stack = createNativeStackNavigator();
|
|
453
|
+
const Tab = createBottomTabNavigator();
|
|
454
|
+
|
|
455
|
+
function HomeTabs() {
|
|
456
|
+
return (
|
|
457
|
+
<Tab.Navigator>
|
|
458
|
+
<Tab.Screen name="Home" component={HomeScreen} />
|
|
459
|
+
<Tab.Screen name="Feed" component={FeedScreen} />
|
|
460
|
+
<Tab.Screen name="Notifications" component={NotificationsScreen} />
|
|
461
|
+
</Tab.Navigator>
|
|
462
|
+
);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
function AppStack() {
|
|
466
|
+
return (
|
|
467
|
+
<Stack.Navigator>
|
|
468
|
+
<Stack.Screen
|
|
469
|
+
name="Main"
|
|
470
|
+
component={HomeTabs}
|
|
471
|
+
options={{
|
|
472
|
+
headerShown: false,
|
|
473
|
+
}}
|
|
474
|
+
/>
|
|
475
|
+
<Stack.Screen name="Profile" component={ProfileScreen} />
|
|
476
|
+
<Stack.Screen name="Settings" component={SettingsScreen} />
|
|
477
|
+
</Stack.Navigator>
|
|
478
|
+
);
|
|
479
|
+
}
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
- Prefer this structure over trying to hide the parent tab bar from screens inside the tab navigator as it can lead to layout glitches.
|
|
483
|
+
- Use [stacks.md](./stacks.md) for stack-specific options on the full-screen routes.
|
|
484
|
+
|
|
485
|
+
## Canonical Docs
|
|
486
|
+
|
|
487
|
+
- [Bottom Tabs Navigator](https://reactnavigation.org/docs/bottom-tab-navigator)
|
|
488
|
+
- [Customizing bottom tab bar](https://reactnavigation.org/docs/customizing-tabbar)
|
|
489
|
+
- [Hiding tab bar in specific screens](https://reactnavigation.org/docs/hiding-tabbar-in-screens)
|
|
490
|
+
|
|
491
|
+
## Related Skills
|
|
492
|
+
|
|
493
|
+
- [header.md](./header.md)
|
|
494
|
+
- [native-bottom-tabs.md](./native-bottom-tabs.md)
|
|
495
|
+
- [material-top-tabs.md](./material-top-tabs.md)
|
|
496
|
+
- [safe-areas.md](./safe-areas.md)
|