Skip to content

Commit 4694e14

Browse files
committed
docs: simplify web platform support guide
Streamline the guide to focus only on platform-specific files (.web.ts/.native.ts) approach. Removed alternative approaches to keep the documentation concise and easier to follow. Changes: - Removed "Custom Tab Bar" approach - Removed "Conditional Platform Rendering" approach - Simplified icon support section - Removed comparison table - Reduced from 265 to 138 lines 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 0852395 commit 4694e14

1 file changed

Lines changed: 5 additions & 132 deletions

File tree

docs/docs/docs/guides/web-platform-support.md

Lines changed: 5 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,7 @@
22

33
React Native Bottom Tabs uses native platform primitives (SwiftUI on iOS and Material Design on Android) which are not available on web. For web applications, you'll need to use JavaScript-based tab implementations as a fallback.
44

5-
## Why Web Requires a Different Approach
6-
7-
Native bottom tabs rely on platform-specific UI components that don't exist in web browsers. React Native Web translates React Native components to web equivalents, but native modules require explicit web implementations.
8-
9-
:::note
10-
11-
Web support requires using platform-specific files or a custom tab bar implementation. This guide shows you both approaches.
12-
13-
:::
14-
15-
## Approach 1: Platform-Specific Files (Recommended)
5+
## How It Works
166

177
React Native's Metro bundler automatically resolves platform-specific files. You can create separate implementations for native platforms and web.
188

@@ -114,118 +104,11 @@ export default function App() {
114104
}
115105
```
116106

117-
## Approach 2: Custom Tab Bar with Standalone Usage
118-
119-
If you're using the standalone `TabView` component, you can provide a custom `tabBar` prop that renders a web-compatible implementation.
120-
121-
```tsx
122-
import { Platform } from 'react-native';
123-
import TabView from 'react-native-bottom-tabs';
124-
125-
function MyTabs() {
126-
const [index, setIndex] = React.useState(0);
127-
const [routes] = React.useState([
128-
{ key: 'home', title: 'Home' },
129-
{ key: 'settings', title: 'Settings' },
130-
]);
131-
132-
const renderScene = SceneMap({
133-
home: HomeScreen,
134-
settings: SettingsScreen,
135-
});
136-
137-
return (
138-
<TabView
139-
navigationState={{ index, routes }}
140-
renderScene={renderScene}
141-
onIndexChange={setIndex}
142-
tabBar={Platform.OS === 'web' ? CustomWebTabBar : undefined}
143-
/>
144-
);
145-
}
146-
```
147-
148-
### Example Custom Web Tab Bar
149-
150-
```tsx
151-
function CustomWebTabBar() {
152-
return (
153-
<View style={styles.tabBar}>
154-
<TouchableOpacity style={styles.tab}>
155-
<Text>Home</Text>
156-
</TouchableOpacity>
157-
<TouchableOpacity style={styles.tab}>
158-
<Text>Settings</Text>
159-
</TouchableOpacity>
160-
</View>
161-
);
162-
}
163-
164-
const styles = StyleSheet.create({
165-
tabBar: {
166-
flexDirection: 'row',
167-
backgroundColor: '#fff',
168-
borderTopWidth: 1,
169-
borderTopColor: '#e0e0e0',
170-
height: 60,
171-
},
172-
tab: {
173-
flex: 1,
174-
justifyContent: 'center',
175-
alignItems: 'center',
176-
},
177-
});
178-
```
179-
180-
## Approach 3: Conditional Platform Rendering
181-
182-
For simpler cases, you can conditionally render different navigators based on platform:
183-
184-
```tsx
185-
import { Platform } from 'react-native';
186-
import { createNativeBottomTabNavigator } from '@bottom-tabs/react-navigation';
187-
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
188-
189-
const NativeTabs = createNativeBottomTabNavigator();
190-
const JSTabs = createBottomTabNavigator();
191-
192-
const Tabs = Platform.OS === 'web' ? JSTabs : NativeTabs;
193-
194-
export function TabNavigator() {
195-
return (
196-
<Tabs.Navigator>
197-
<Tabs.Screen name="Home" component={HomeScreen} />
198-
<Tabs.Screen name="Settings" component={SettingsScreen} />
199-
</Tabs.Navigator>
200-
);
201-
}
202-
```
203-
204-
:::warning
205-
206-
This approach requires installing both `@bottom-tabs/react-navigation` and `@react-navigation/bottom-tabs`, which increases bundle size for all platforms.
207-
208-
:::
209-
210-
## Styling Considerations
211-
212-
When implementing web tabs, consider these styling differences:
107+
## Icon Support
213108

214-
### Native Platforms
215-
- Use `sfSymbol` for iOS icons
216-
- Platform-specific appearance attributes
217-
- Native gestures and animations
109+
On web, you cannot use SF Symbols. Instead, use cross-platform icon libraries:
218110

219-
### Web Platform
220-
- Use web-compatible icon libraries (e.g., `react-icons`, `@expo/vector-icons`)
221-
- CSS-based styling and animations
222-
- Standard web accessibility practices
223-
224-
## Icon Libraries for Web
225-
226-
For web compatibility, use icon libraries that work across all platforms:
227-
228-
### Expo Vector Icons
111+
**Expo Vector Icons** (recommended):
229112

230113
```tsx
231114
import { Ionicons } from '@expo/vector-icons';
@@ -237,7 +120,7 @@ options={{
237120
}}
238121
```
239122

240-
### React Icons
123+
**React Icons:**
241124

242125
```tsx
243126
import { FiHome } from 'react-icons/fi';
@@ -247,16 +130,6 @@ options={{
247130
}}
248131
```
249132

250-
## Summary
251-
252-
| Approach | Pros | Cons |
253-
|----------|------|------|
254-
| **Platform-Specific Files** | Clean separation, optimal bundle size | Requires maintaining two implementations |
255-
| **Custom Tab Bar** | Full control, single codebase | More code to maintain |
256-
| **Conditional Rendering** | Simple to understand | Both libraries in bundle |
257-
258-
For most projects, **platform-specific files** provide the best balance of code organization, bundle size, and developer experience.
259-
260133
## Additional Resources
261134

262135
- [React Navigation Bottom Tabs](https://reactnavigation.org/docs/bottom-tab-navigator/)

0 commit comments

Comments
 (0)