Skip to content

Commit e01445f

Browse files
feat(breaking): create tabBarStyle (#239)
1 parent e83e0f2 commit e01445f

File tree

7 files changed

+37
-18
lines changed

7 files changed

+37
-18
lines changed

.changeset/rare-berries-rush.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'react-native-bottom-tabs': minor
3+
---
4+
5+
feat!: add tabBarStyle, remove barTintColor prop

apps/example/src/App.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ const FourTabsOpaqueScrollEdgeAppearance = () => {
5252
return <FourTabs scrollEdgeAppearance="opaque" />;
5353
};
5454

55-
const FourTabsWithBarTintColor = () => {
56-
return <FourTabs barTintColor={'#87CEEB'} />;
55+
const FourTabsWithBackgroundColor = () => {
56+
return <FourTabs backgroundColor={'#87CEEB'} />;
5757
};
5858

5959
const FourTabsTranslucent = () => {
@@ -108,7 +108,7 @@ const examples = [
108108
platform: 'ios',
109109
},
110110
{
111-
component: FourTabsWithBarTintColor,
111+
component: FourTabsWithBackgroundColor,
112112
name: 'Four Tabs - Custom Background Color of Tabs',
113113
},
114114
{

apps/example/src/Examples/FourTabs.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ interface Props {
1010
ignoresTopSafeArea?: boolean;
1111
disablePageAnimations?: boolean;
1212
scrollEdgeAppearance?: 'default' | 'opaque' | 'transparent';
13-
barTintColor?: ColorValue;
13+
backgroundColor?: ColorValue;
1414
translucent?: boolean;
1515
hideOneTab?: boolean;
1616
rippleColor?: ColorValue;
@@ -21,7 +21,7 @@ export default function FourTabs({
2121
ignoresTopSafeArea = false,
2222
disablePageAnimations = false,
2323
scrollEdgeAppearance = 'default',
24-
barTintColor,
24+
backgroundColor,
2525
translucent = true,
2626
hideOneTab = false,
2727
rippleColor,
@@ -71,7 +71,7 @@ export default function FourTabs({
7171
navigationState={{ index, routes }}
7272
onIndexChange={setIndex}
7373
renderScene={renderScene}
74-
barTintColor={barTintColor}
74+
tabBarStyle={{ backgroundColor }}
7575
translucent={translucent}
7676
rippleColor={rippleColor}
7777
activeIndicatorColor={activeIndicatorColor}

apps/example/src/Examples/NativeBottomTabs.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ function NativeBottomTabs() {
1515
hapticFeedbackEnabled={false}
1616
tabBarInactiveTintColor="#C57B57"
1717
tabBarActiveTintColor="#F7DBA7"
18-
barTintColor="#1E2D2F"
18+
tabBarStyle={{
19+
backgroundColor: '#1E2D2F',
20+
}}
1921
rippleColor="#F7DBA7"
2022
tabLabelStyle={{
2123
fontFamily: 'Avenir',

docs/docs/docs/guides/standalone-usage.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,16 @@ Color for the active tab.
156156
#### `tabBarInactiveTintColor`
157157

158158
Color for inactive tabs.
159+
159160
- Type: `ColorValue`
160161

161-
#### `barTintColor`
162+
#### `tabBarStyle`
162163

163-
Background color of the tab bar.
164-
- Type: `ColorValue`
164+
Object containing styles for the tab bar.
165+
166+
Supported properties:
167+
168+
- `backgroundColor`: Background color of the tab bar.
165169

166170
#### `translucent` <Badge text="iOS" type="info" />
167171

docs/docs/docs/guides/usage-with-react-navigation.mdx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ It supports the following values:
9696
#### `labeled`
9797

9898
Whether to show labels in tabs.
99+
99100
- Type: `boolean`
100101
- Default <Badge text="iOS" type="info" />: `true`
101102
- Default <Badge text="Android" type="info" />: `false`
@@ -130,9 +131,13 @@ Color for the active tab.
130131

131132
Color for the inactive tabs.
132133

133-
#### `barTintColor`
134+
#### `tabBarStyle`
135+
136+
Object containing styles for the tab bar.
137+
138+
Supported properties:
134139

135-
Background color of the tab bar.
140+
- `backgroundColor`: Background color of the tab bar.
136141

137142
#### `activeIndicatorColor` <Badge text="android" type="info" />
138143

packages/react-native-bottom-tabs/src/TabView.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,13 @@ interface Props<Route extends BaseRoute> {
116116
*/
117117
getTestID?: (props: { route: Route }) => string | undefined;
118118

119-
/**
120-
* Background color of the tab bar.
121-
*/
122-
barTintColor?: ColorValue;
119+
tabBarStyle?: {
120+
/**
121+
* Background color of the tab bar.
122+
*/
123+
backgroundColor?: ColorValue;
124+
};
125+
123126
/**
124127
* A Boolean value that indicates whether the tab bar is translucent. (iOS only)
125128
*/
@@ -166,10 +169,10 @@ const TabView = <Route extends BaseRoute>({
166169
? route.focusedIcon
167170
: route.unfocusedIcon
168171
: route.focusedIcon,
169-
barTintColor,
170172
getHidden = ({ route }: { route: Route }) => route.hidden,
171173
getActiveTintColor = ({ route }: { route: Route }) => route.activeTintColor,
172174
getTestID = ({ route }: { route: Route }) => route.testID,
175+
tabBarStyle,
173176
hapticFeedbackEnabled = false,
174177
tabLabelStyle,
175178
...props
@@ -290,7 +293,7 @@ const TabView = <Route extends BaseRoute>({
290293
hapticFeedbackEnabled={hapticFeedbackEnabled}
291294
activeTintColor={activeTintColor}
292295
inactiveTintColor={inactiveTintColor}
293-
barTintColor={barTintColor}
296+
barTintColor={tabBarStyle?.backgroundColor}
294297
rippleColor={rippleColor}
295298
>
296299
{trimmedRoutes.map((route) => {

0 commit comments

Comments
 (0)