Skip to content

Commit 9673d46

Browse files
okwasniewskiclaude
andauthored
docs: add web platform support guide (#455)
* docs: add web platform support guide Add comprehensive documentation for web platform support showing how to use platform-specific files (.web.ts/.native.ts) or custom tab bars to provide JavaScript-based tab implementations on web. The guide includes: - Explanation of why web requires a different approach - Three implementation approaches with pros/cons - Code examples for each approach - Icon library recommendations for cross-platform support - Styling considerations between native and web platforms Updated README and introduction to reference the new web platform guide. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * 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 <[email protected]> * docs: update icon examples to match codebase patterns Updated web platform support guide to reflect actual icon handling patterns used in the example app: - Show Platform.OS conditional for iOS SF Symbols vs Android/web PNG assets - Use require() for PNG/SVG files instead of icon component libraries - Add focused/unfocused icon pattern example - Remove icon library examples in favor of image asset approach - Demonstrate cross-platform pattern that works on iOS, Android, and web This matches the patterns in apps/example/src/Examples/ directory. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Apply suggestion from @okwasniewski --------- Co-authored-by: Claude <[email protected]>
1 parent 6b68b65 commit 9673d46

File tree

4 files changed

+124
-1
lines changed

4 files changed

+124
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ https://github.com/user-attachments/assets/09e96ac3-827d-4ac0-add0-e7b88ee9197c
2929
| **tvOS** | <img src="https://github.com/user-attachments/assets/2fe8483d-73f9-408f-9315-100eee7bf2af" width="400" /> |
3030
| **macOS** | <img src="https://github.com/user-attachments/assets/758decf4-6e70-4c55-8f2d-c16927f2c56d" width="400" /> |
3131

32+
> **Note:** This library uses native platform primitives which are not available on web. For web support, see the [Web Platform Support guide](https://oss.callstack.com/react-native-bottom-tabs/docs/guides/web-platform-support) in the documentation.
33+
3234
## Package Versions
3335

3436
| Name | Latest Version |

docs/docs/docs/getting-started/introduction.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,9 @@ React Native Bottom Tabs is a library that provides a native bottom tabs experie
1010
- visionOS
1111
- tvOS
1212
- macOS
13+
14+
:::note
15+
16+
For **web** platform support, native tabs are not available. See the [Web Platform Support](/docs/guides/web-platform-support) guide for JavaScript-based alternatives.
17+
18+
:::

docs/docs/docs/guides/_meta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
["usage-with-react-navigation", "usage-with-expo-router", "usage-with-one", "standalone-usage", {"type": "divider"}, "handling-scrollview-insets", "usage-with-vector-icons", {"type": "divider"}, "android-native-styling", "edge-to-edge-support"]
1+
["usage-with-react-navigation", "usage-with-expo-router", "usage-with-one", "standalone-usage", {"type": "divider"}, "web-platform-support", "handling-scrollview-insets", "usage-with-vector-icons", {"type": "divider"}, "android-native-styling", "edge-to-edge-support"]
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# Web Platform Support
2+
3+
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.
4+
5+
## How It Works
6+
7+
React Native's Metro bundler automatically resolves platform-specific files. You can create separate implementations for native platforms and web.
8+
9+
### File Structure
10+
11+
```
12+
src/
13+
├── navigation/
14+
│ ├── TabNavigator.native.tsx # Used on iOS/Android
15+
│ └── TabNavigator.web.tsx # Used on web
16+
```
17+
18+
### Native Implementation
19+
20+
```tsx title="TabNavigator.native.tsx"
21+
import { createNativeBottomTabNavigator } from '@bottom-tabs/react-navigation';
22+
import { Platform } from 'react-native';
23+
import { HomeScreen } from '../screens/HomeScreen';
24+
import { SettingsScreen } from '../screens/SettingsScreen';
25+
26+
const Tabs = createNativeBottomTabNavigator();
27+
28+
export function TabNavigator() {
29+
return (
30+
<Tabs.Navigator>
31+
<Tabs.Screen
32+
name="Home"
33+
component={HomeScreen}
34+
options={{
35+
tabBarIcon: () =>
36+
Platform.OS === 'ios'
37+
? { sfSymbol: 'house' }
38+
: require('../assets/icons/home.png'),
39+
}}
40+
/>
41+
<Tabs.Screen
42+
name="Settings"
43+
component={SettingsScreen}
44+
options={{
45+
tabBarIcon: () =>
46+
Platform.OS === 'ios'
47+
? { sfSymbol: 'gear' }
48+
: require('../assets/icons/settings.png'),
49+
}}
50+
/>
51+
</Tabs.Navigator>
52+
);
53+
}
54+
```
55+
56+
### Web Implementation
57+
58+
For web, install `@react-navigation/bottom-tabs` which provides a JavaScript-based implementation:
59+
60+
```bash
61+
npm install @react-navigation/bottom-tabs
62+
```
63+
64+
```tsx title="TabNavigator.web.tsx"
65+
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
66+
import { HomeScreen } from '../screens/HomeScreen';
67+
import { SettingsScreen } from '../screens/SettingsScreen';
68+
69+
const Tab = createBottomTabNavigator();
70+
71+
export function TabNavigator() {
72+
return (
73+
<Tab.Navigator>
74+
<Tab.Screen
75+
name="Home"
76+
component={HomeScreen}
77+
options={{
78+
tabBarIcon: () => require('../assets/icons/home.png'),
79+
}}
80+
/>
81+
<Tab.Screen
82+
name="Settings"
83+
component={SettingsScreen}
84+
options={{
85+
tabBarIcon: () => require('../assets/icons/settings.png'),
86+
}}
87+
/>
88+
</Tab.Navigator>
89+
);
90+
}
91+
```
92+
93+
### Using in Your App
94+
95+
Import the component normally - React Native will automatically use the correct file:
96+
97+
```tsx title="App.tsx"
98+
import { NavigationContainer } from '@react-navigation/native';
99+
import { TabNavigator } from './navigation/TabNavigator';
100+
101+
export default function App() {
102+
return (
103+
<NavigationContainer>
104+
<TabNavigator />
105+
</NavigationContainer>
106+
);
107+
}
108+
```
109+
110+
111+
## Additional Resources
112+
113+
- [React Navigation Bottom Tabs](https://reactnavigation.org/docs/bottom-tab-navigator/)
114+
- [React Native Web Documentation](https://necolas.github.io/react-native-web/)
115+
- [Metro Bundler Platform-Specific Extensions](https://reactnative.dev/docs/platform-specific-code#platform-specific-extensions)

0 commit comments

Comments
 (0)