Bottom Tabs that use native platform primitives.
Caution
This library is in early development and not ready for production use.
5ABUrqNBjnUC5Zay.mp4
yarn add react-native-bottom-tabs
If you use React Native version 0.75 or lower:
- For
@react-native-community/cli
users, open Podfile in ios folder and change minimum iOS version to14.0
beforepod install
-platform :ios, min_ios_version_supported
+platform :ios, '14.0'
- For Expo users, install
expo-build-properties
, open app.json file and updatedeploymentTarget
forios
as below
{
"expo": {
"plugins": [
[
"expo-build-properties",
{
"ios": {
"deploymentTarget": "14.0"
}
}
]
],
}
}
Check this demo and instructions: EvanBacon/expo-router-react-native-bottom-tabs
Note
To use this navigator, ensure that you have @react-navigation/native
and its dependencies (follow this guide):
Example usage:
import {createNativeBottomTabNavigator} from 'react-native-bottom-tabs/react-navigation';
const Tab = createNativeBottomTabNavigator();
function NativeBottomTabs() {
return (
<Tab.Navigator>
<Tab.Screen
name="Article"
component={Article}
options={{
tabBarBadge: '10',
tabBarIcon: ({ focused }) =>
focused
? require('person.png')
: require('article.png'),
}}
/>
<Tab.Screen
name="Albums"
component={Albums}
options={{
tabBarIcon: () => require('grid.png'),
}}
/>
</Tab.Navigator>
);
}
The Tab.Navigator
component accepts following props:
Optional unique ID for the navigator. This can be used with navigation.getParent
to refer to this navigator in a child navigator.
The name of the route to render on first load of the navigator.
Default options to use for the screens in the navigator.
Whether to show labels in tabs. Defaults to true.
A tab bar style that adapts to each platform. (Apple platforms only)
Tab views using the sidebar adaptable style have an appearance
- iPadOS displays a top tab bar that can adapt into a sidebar.
- iOS displays a bottom tab bar.
- macOS and tvOS always show a sidebar.
- visionOS shows an ornament and also shows a sidebar for secondary tabs within a
TabSection
.
The following options can be used to configure the screens in the navigator. These can be specified under screenOptions
prop of Tab.navigator
or options
prop of Tab.Screen
.
Title text for the screen.
Label text of the tab displayed in the navigation bar. When undefined, scene title is used.
Function that given { focused: boolean } returns ImageSource or AppleIcon to display in the navigation bar.
Note: SF Symbols are only supported on Apple platforms.
<Tab.Screen
name="Albums"
component={Albums}
options={{
tabBarIcon: () => require('person.png'),
// or
tabBarIcon: () => ({ sfSymbol: 'person' }),
}}
/>
Badge to show on the tab icon.
Whether this screens should render the first time it's accessed. Defaults to true. Set it to false if you want to render the screen on initial render.
If you don't use React Navigation, you can use the TabView
component directly.
import TabView, { SceneMap } from 'react-native-bottom-tabs';
export default function ThreeTabs() {
const [index, setIndex] = useState(0);
const [routes] = useState([
{ key: 'article', title: 'Article', focusedIcon: require('article.png'), badge: '!' },
{
key: 'albums',
title: 'Albums',
focusedIcon: require('grid.png'),
badge: '5',
},
{ key: 'contacts', title: 'Contacts', focusedIcon: require('person.png') },
]);
const renderScene = SceneMap({
article: Article,
albums: Albums,
contacts: Contacts,
});
return (
<TabView
navigationState={{ index, routes }}
onIndexChange={setIndex}
renderScene={renderScene}
/>
);
}
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT
Made with β€οΈ and create-react-native-library