-
Notifications
You must be signed in to change notification settings - Fork 99
fix(TabView): respect user-supplied tabBarHidden #524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
thiagobrez
merged 6 commits into
callstack:main
from
spokodev:fix/tab-bar-hidden-respects-user-prop
Jun 10, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
462f613
fix(TabView): respect user-supplied tabBarHidden
spokodev 8d45171
chore: address PR comments
thiagobrez ca8fed7
Merge branch 'main' into fix/tab-bar-hidden-respects-user-prop
thiagobrez ed4e467
chore: add tabBarHidden examples
thiagobrez e374ec4
refactor(TabView): drop unreachable tabBarHidden fallback
spokodev a55b5a9
chore: fix custom tabBar behavior with tabBarHidden and add more exam…
thiagobrez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| 'react-native-bottom-tabs': patch | ||
| --- | ||
|
|
||
| Respect user-supplied `tabBarHidden` on `TabView`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| import TabView from 'react-native-bottom-tabs'; | ||
| import { useState } from 'react'; | ||
| import { Pressable, StyleSheet, Text, View } from 'react-native'; | ||
|
|
||
| const routes = [ | ||
| { | ||
| key: 'article', | ||
| title: 'Article', | ||
| focusedIcon: require('../../assets/icons/article_dark.png'), | ||
| }, | ||
| { | ||
| key: 'albums', | ||
| title: 'Albums', | ||
| focusedIcon: require('../../assets/icons/grid_dark.png'), | ||
| }, | ||
| { | ||
| key: 'contacts', | ||
| title: 'Contacts', | ||
| focusedIcon: require('../../assets/icons/person_dark.png'), | ||
| }, | ||
| ]; | ||
|
|
||
| export default function CustomTabBar() { | ||
| const [index, setIndex] = useState(0); | ||
|
|
||
| return ( | ||
| <TabView | ||
| sidebarAdaptable | ||
| navigationState={{ index, routes }} | ||
| onIndexChange={setIndex} | ||
| renderScene={({ route }) => ( | ||
| <View style={styles.screen}> | ||
| <Text style={styles.title}>{route.title}</Text> | ||
| </View> | ||
| )} | ||
| tabBar={() => ( | ||
| <View style={styles.customTabBar}> | ||
| {routes.map((route, routeIndex) => { | ||
| const focused = routeIndex === index; | ||
|
|
||
| return ( | ||
| <Pressable | ||
| key={route.key} | ||
| style={[ | ||
| styles.customTabBarItem, | ||
| focused && styles.customTabBarItemFocused, | ||
| ]} | ||
| onPress={() => setIndex(routeIndex)} | ||
| > | ||
| <Text | ||
| style={[ | ||
| styles.customTabBarLabel, | ||
| focused && styles.customTabBarLabelFocused, | ||
| ]} | ||
| > | ||
| {route.title} | ||
| </Text> | ||
| </Pressable> | ||
| ); | ||
| })} | ||
| </View> | ||
| )} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| screen: { | ||
| flex: 1, | ||
| alignItems: 'center', | ||
| justifyContent: 'center', | ||
| padding: 24, | ||
| }, | ||
| title: { | ||
| fontSize: 24, | ||
| fontWeight: '600', | ||
| }, | ||
| customTabBar: { | ||
| flexDirection: 'row', | ||
| gap: 8, | ||
| paddingHorizontal: 12, | ||
| paddingTop: 10, | ||
| paddingBottom: 18, | ||
| backgroundColor: '#24292f', | ||
| }, | ||
| customTabBarItem: { | ||
| flex: 1, | ||
| alignItems: 'center', | ||
| justifyContent: 'center', | ||
| minHeight: 44, | ||
| borderRadius: 6, | ||
| backgroundColor: '#3b434c', | ||
| }, | ||
| customTabBarItemFocused: { | ||
| backgroundColor: '#ffffff', | ||
| }, | ||
| customTabBarLabel: { | ||
| color: '#ffffff', | ||
| fontWeight: '600', | ||
| }, | ||
| customTabBarLabelFocused: { | ||
| color: '#24292f', | ||
| }, | ||
| }); |
93 changes: 93 additions & 0 deletions
93
apps/example/src/Examples/NativeBottomTabsTabBarHidden.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| import { createNativeBottomTabNavigator } from '@bottom-tabs/react-navigation'; | ||
| import { useState } from 'react'; | ||
| import { Button, StyleSheet, Text, View } from 'react-native'; | ||
|
|
||
| const Tab = createNativeBottomTabNavigator(); | ||
|
|
||
| type TabBarHiddenScreenProps = { | ||
| title: string; | ||
| tabBarHidden: boolean; | ||
| onToggleTabBarHidden: () => void; | ||
| }; | ||
|
|
||
| function TabBarHiddenScreen({ | ||
| title, | ||
| tabBarHidden, | ||
| onToggleTabBarHidden, | ||
| }: TabBarHiddenScreenProps) { | ||
| return ( | ||
| <View style={styles.screen}> | ||
| <Text style={styles.title}>{title}</Text> | ||
| <Button | ||
| title={`${tabBarHidden ? 'Show' : 'Hide'} Tab Bar`} | ||
| onPress={onToggleTabBarHidden} | ||
| /> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| export default function NativeBottomTabsTabBarHidden() { | ||
| const [tabBarHidden, setTabBarHidden] = useState(false); | ||
| const toggleTabBarHidden = () => setTabBarHidden((value) => !value); | ||
|
|
||
| return ( | ||
| <Tab.Navigator sidebarAdaptable tabBarHidden={tabBarHidden}> | ||
| <Tab.Screen | ||
| name="Article" | ||
| options={{ | ||
| tabBarIcon: () => require('../../assets/icons/article_dark.png'), | ||
| }} | ||
| > | ||
| {() => ( | ||
| <TabBarHiddenScreen | ||
| title="Article" | ||
| tabBarHidden={tabBarHidden} | ||
| onToggleTabBarHidden={toggleTabBarHidden} | ||
| /> | ||
| )} | ||
| </Tab.Screen> | ||
| <Tab.Screen | ||
| name="Albums" | ||
| options={{ | ||
| tabBarIcon: () => require('../../assets/icons/grid_dark.png'), | ||
| }} | ||
| > | ||
| {() => ( | ||
| <TabBarHiddenScreen | ||
| title="Albums" | ||
| tabBarHidden={tabBarHidden} | ||
| onToggleTabBarHidden={toggleTabBarHidden} | ||
| /> | ||
| )} | ||
| </Tab.Screen> | ||
| <Tab.Screen | ||
| name="Contacts" | ||
| options={{ | ||
| tabBarIcon: () => require('../../assets/icons/person_dark.png'), | ||
| }} | ||
| > | ||
| {() => ( | ||
| <TabBarHiddenScreen | ||
| title="Contacts" | ||
| tabBarHidden={tabBarHidden} | ||
| onToggleTabBarHidden={toggleTabBarHidden} | ||
| /> | ||
| )} | ||
| </Tab.Screen> | ||
| </Tab.Navigator> | ||
| ); | ||
| } | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| screen: { | ||
| flex: 1, | ||
| alignItems: 'center', | ||
| justifyContent: 'center', | ||
| gap: 16, | ||
| padding: 24, | ||
| }, | ||
| title: { | ||
| fontSize: 24, | ||
| fontWeight: '600', | ||
| }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| import TabView from 'react-native-bottom-tabs'; | ||
| import { useState } from 'react'; | ||
| import { Button, StyleSheet, Text, View } from 'react-native'; | ||
|
|
||
| const routes = [ | ||
| { | ||
| key: 'article', | ||
| title: 'Article', | ||
| focusedIcon: require('../../assets/icons/article_dark.png'), | ||
| }, | ||
| { | ||
| key: 'albums', | ||
| title: 'Albums', | ||
| focusedIcon: require('../../assets/icons/grid_dark.png'), | ||
| }, | ||
| { | ||
| key: 'contacts', | ||
| title: 'Contacts', | ||
| focusedIcon: require('../../assets/icons/person_dark.png'), | ||
| }, | ||
| ]; | ||
|
|
||
| type TabBarHiddenScreenProps = { | ||
| title: string; | ||
| tabBarHidden: boolean; | ||
| onToggleTabBarHidden: () => void; | ||
| }; | ||
|
|
||
| function TabBarHiddenScreen({ | ||
| title, | ||
| tabBarHidden, | ||
| onToggleTabBarHidden, | ||
| }: TabBarHiddenScreenProps) { | ||
| return ( | ||
| <View style={styles.screen}> | ||
| <Text style={styles.title}>{title}</Text> | ||
| <Button | ||
| title={`${tabBarHidden ? 'Show' : 'Hide'} Tab Bar`} | ||
| onPress={onToggleTabBarHidden} | ||
| /> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| export default function TabBarHidden() { | ||
| const [index, setIndex] = useState(0); | ||
| const [tabBarHidden, setTabBarHidden] = useState(false); | ||
|
|
||
| return ( | ||
| <TabView | ||
| sidebarAdaptable | ||
| navigationState={{ index, routes }} | ||
| onIndexChange={setIndex} | ||
| renderScene={({ route }) => ( | ||
| <TabBarHiddenScreen | ||
| title={route.title} | ||
| tabBarHidden={tabBarHidden} | ||
| onToggleTabBarHidden={() => setTabBarHidden((value) => !value)} | ||
| /> | ||
| )} | ||
| tabBarHidden={tabBarHidden} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| screen: { | ||
| flex: 1, | ||
| alignItems: 'center', | ||
| justifyContent: 'center', | ||
| gap: 16, | ||
| padding: 24, | ||
| }, | ||
| title: { | ||
| fontSize: 24, | ||
| fontWeight: '600', | ||
| }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.