|
11 | 11 |
|
12 | 12 | https://github.com/user-attachments/assets/fbdd9ce2-f4b9-4d0c-bd91-2e62bb422d69 |
13 | 13 |
|
14 | | -## 📦 Installation |
| 14 | +## Documentation |
15 | 15 |
|
16 | | -```sh |
17 | | -yarn add react-native-bottom-tabs |
18 | | -``` |
19 | | - |
20 | | -If you use React Native version 0.75 or lower: |
21 | | - |
22 | | -- For `@react-native-community/cli` users, open Podfile in ios folder and change minimum iOS version to `14.0` before `pod install` |
23 | | - |
24 | | -```patch |
25 | | --platform :ios, min_ios_version_supported |
26 | | -+platform :ios, '14.0' |
27 | | -``` |
28 | | - |
29 | | -- For Expo users, install `expo-build-properties`, open app.json file and update `deploymentTarget` for `ios` as below |
30 | | - |
31 | | -```json |
32 | | -{ |
33 | | - "expo": { |
34 | | - "plugins": [ |
35 | | - [ |
36 | | - "expo-build-properties", |
37 | | - { |
38 | | - "ios": { |
39 | | - "deploymentTarget": "14.0" |
40 | | - } |
41 | | - } |
42 | | - ] |
43 | | - ], |
44 | | - } |
45 | | -} |
46 | | -``` |
47 | | - |
48 | | -## 📖 Documentation |
49 | | - |
50 | | -### Usage with Expo Router |
51 | | - |
52 | | -Check this demo and instructions: [EvanBacon/expo-router-react-native-bottom-tabs]( https://github.com/EvanBacon/expo-router-react-native-bottom-tabs) |
53 | | - |
54 | | -### Usage with React Navigation |
55 | | - |
56 | | -> [!NOTE] |
57 | | -> To use this navigator, ensure that you have [`@react-navigation/native` and its dependencies (follow this guide)](https://reactnavigation.org/docs/getting-started): |
58 | | -
|
59 | | -Example usage: |
60 | | - |
61 | | -```tsx |
62 | | -import {createNativeBottomTabNavigator} from 'react-native-bottom-tabs/react-navigation'; |
63 | | - |
64 | | -const Tab = createNativeBottomTabNavigator(); |
65 | | - |
66 | | -function NativeBottomTabs() { |
67 | | - return ( |
68 | | - <Tab.Navigator> |
69 | | - <Tab.Screen |
70 | | - name="Article" |
71 | | - component={Article} |
72 | | - options={{ |
73 | | - tabBarBadge: '10', |
74 | | - tabBarIcon: ({ focused }) => |
75 | | - focused |
76 | | - ? require('person.png') |
77 | | - : require('article.png'), |
78 | | - }} |
79 | | - /> |
80 | | - <Tab.Screen |
81 | | - name="Albums" |
82 | | - component={Albums} |
83 | | - options={{ |
84 | | - tabBarIcon: () => require('grid.png'), |
85 | | - }} |
86 | | - /> |
87 | | - </Tab.Navigator> |
88 | | - ); |
89 | | -} |
90 | | -``` |
91 | | - |
92 | | -### Props |
93 | | - |
94 | | -The `Tab.Navigator` component accepts following props: |
95 | | - |
96 | | -#### `id` |
97 | | - |
98 | | -Optional unique ID for the navigator. This can be used with `navigation.getParent` to refer to this navigator in a child navigator. |
99 | | - |
100 | | -#### `initialRouteName` |
101 | | - |
102 | | -The name of the route to render on first load of the navigator. |
103 | | - |
104 | | -#### `screenOptions` |
105 | | - |
106 | | -Default options to use for the screens in the navigator. |
107 | | - |
108 | | -#### `labeled` |
109 | | - |
110 | | -Whether to show labels in tabs. Defaults to true. |
111 | | - |
112 | | -#### `disablePageAnimations` |
113 | | - |
114 | | -Whether to disable page animations between tabs. (iOS only) |
115 | | - |
116 | | -#### `sidebarAdaptable` |
117 | | - |
118 | | -A tab bar style that adapts to each platform. (Apple platforms only) |
119 | | - |
120 | | -Tab views using the sidebar adaptable style have an appearance |
121 | | -- iPadOS displays a top tab bar that can adapt into a sidebar. |
122 | | -- iOS displays a bottom tab bar. |
123 | | -- macOS and tvOS always show a sidebar. |
124 | | -- visionOS shows an ornament and also shows a sidebar for secondary tabs within a `TabSection`. |
125 | | - |
126 | | - |
127 | | -### Options |
128 | | - |
129 | | -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`. |
130 | | - |
131 | | -#### `title` |
132 | | - |
133 | | -Title text for the screen. |
134 | | - |
135 | | -#### `tabBarLabel` |
136 | | - |
137 | | -Label text of the tab displayed in the navigation bar. When undefined, scene title is used. |
138 | | - |
139 | | -#### `tabBarIcon` |
140 | | - |
141 | | -Function that given { focused: boolean } returns ImageSource or AppleIcon to display in the navigation bar. |
142 | | - |
143 | | -Note: SF Symbols are only supported on Apple platforms. |
144 | | - |
145 | | -```tsx |
146 | | -<Tab.Screen |
147 | | - name="Albums" |
148 | | - component={Albums} |
149 | | - options={{ |
150 | | - tabBarIcon: () => require('person.png'), |
151 | | - // or |
152 | | - tabBarIcon: () => ({ sfSymbol: 'person' }), |
153 | | - }} |
154 | | -/> |
155 | | - |
156 | | -``` |
157 | | - |
158 | | -#### `tabBarBadge` |
159 | | - |
160 | | -Badge to show on the tab icon. |
161 | | - |
162 | | -#### `lazy` |
163 | | - |
164 | | -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. |
165 | | - |
166 | | - |
167 | | -### Usage without React Navigation |
168 | | - |
169 | | -If you don't use React Navigation, you can use the `TabView` component directly. |
170 | | - |
171 | | - |
172 | | -```tsx |
173 | | -import TabView, { SceneMap } from 'react-native-bottom-tabs'; |
174 | | - |
175 | | -export default function ThreeTabs() { |
176 | | - const [index, setIndex] = useState(0); |
177 | | - const [routes] = useState([ |
178 | | - { key: 'article', title: 'Article', focusedIcon: require('article.png'), badge: '!' }, |
179 | | - { |
180 | | - key: 'albums', |
181 | | - title: 'Albums', |
182 | | - focusedIcon: require('grid.png'), |
183 | | - badge: '5', |
184 | | - }, |
185 | | - { key: 'contacts', title: 'Contacts', focusedIcon: require('person.png') }, |
186 | | - ]); |
187 | | - |
188 | | - const renderScene = SceneMap({ |
189 | | - article: Article, |
190 | | - albums: Albums, |
191 | | - contacts: Contacts, |
192 | | - }); |
193 | | - |
194 | | - return ( |
195 | | - <TabView |
196 | | - navigationState={{ index, routes }} |
197 | | - onIndexChange={setIndex} |
198 | | - renderScene={renderScene} |
199 | | - /> |
200 | | - ); |
201 | | -} |
202 | | -``` |
203 | | - |
204 | | -### ScrollView |
205 | | - |
206 | | -If you expirence issues with ScrollView content being below the tab bar, add `contentInsetAdjustmentBehavior="automatic"` to the ScrollView component. |
207 | | - |
208 | | - |
209 | | -```tsx |
210 | | -<ScrollView contentInsetAdjustmentBehavior="automatic"> |
211 | | - {/* content */} |
212 | | -</ScrollView> |
213 | | -``` |
| 16 | +The full documentation can be found on our [website](). |
214 | 17 |
|
215 | 18 | ## Contributing |
216 | 19 |
|
|
0 commit comments