Skip to content

Commit 7901361

Browse files
lidord-wixethanshar
authored andcommitted
Fix/ TabBar backgroundColor (#2014)
1 parent efd051a commit 7901361

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

src/components/tabController/TabBar.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ import _ from 'lodash';
55

66
import TabBarContext from './TabBarContext';
77
import TabBarItem, {TabControllerItemProps} from './TabBarItem';
8-
import {Constants, asBaseComponent, forwardRef, BaseComponentInjectedProps, ForwardRefInjectedProps} from '../../commons/new';
8+
import {
9+
Constants,
10+
asBaseComponent,
11+
forwardRef,
12+
BaseComponentInjectedProps,
13+
ForwardRefInjectedProps
14+
} from '../../commons/new';
915
import View from '../view';
1016
import {Colors, Spacings, Typography} from '../../style';
1117
import FadedScrollView from '../fadedScrollView';
@@ -210,6 +216,7 @@ const TabBar = (props: Props) => {
210216
uppercase={uppercase}
211217
iconColor={iconColor}
212218
selectedIconColor={selectedIconColor}
219+
backgroundColor={backgroundColor}
213220
activeBackgroundColor={activeBackgroundColor}
214221
{...item}
215222
{...context}
@@ -228,6 +235,7 @@ const TabBar = (props: Props) => {
228235
uppercase,
229236
iconColor,
230237
selectedIconColor,
238+
backgroundColor,
231239
activeBackgroundColor,
232240
centerSelected,
233241
onItemLayout

src/components/tabController/TabBarItem.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ export interface TabControllerItemProps {
7878
* The active opacity when pressing a tab
7979
*/
8080
activeOpacity?: number;
81+
/**
82+
* Apply background color for the tab bar item
83+
*/
84+
backgroundColor?: string;
8185
/**
8286
* TODO: rename to feedbackColor
8387
* Apply background color on press for TouchableOpacity
@@ -118,6 +122,7 @@ export default function TabBarItem({
118122
trailingAccessory,
119123
uppercase,
120124
activeOpacity = 0.9,
125+
backgroundColor = Colors.$backgroundElevated,
121126
activeBackgroundColor,
122127
testID,
123128
ignore,
@@ -192,8 +197,8 @@ export default function TabBarItem({
192197
// @ts-expect-error
193198
ref={itemRef}
194199
style={_style}
195-
bg-$backgroundElevated
196200
onLayout={onLayout}
201+
backgroundColor={backgroundColor}
197202
activeBackgroundColor={activeBackgroundColor}
198203
activeOpacity={activeOpacity}
199204
onPress={onPress}

src/components/tabController/apis/tabBarItem.api.json

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99
{"name": "labelStyle;", "type": "TextStyle", "description": "Custom label style"},
1010
{"name": "selectedLabelStyle", "type": "TextStyle", "description": "Custom selected label style"},
1111
{"name": "labelColor", "type": "string", "description": "The default label color", "default": "Colors.black"},
12-
{"name": "selectedLabelColor", "type": "string", "description": "The selected label color", "default": "Colors.primary"},
12+
{
13+
"name": "selectedLabelColor",
14+
"type": "string",
15+
"description": "The selected label color",
16+
"default": "Colors.primary"
17+
},
1318
{"name": "icon", "type": "number", "description": "Icon of the tab"},
1419
{"name": "iconColor", "type": "string", "description": "Icon tint color"},
1520
{"name": "selectedIconColor", "type": "string", "description": "Icon selected tint color"},
@@ -21,6 +26,11 @@
2126
{"name": "onPress", "type": "(index: number) => void", "description": "Callback for when pressing a tab"},
2227
{"name": "uppercase", "type": "boolean", "description": "Whether to change the text to uppercase"},
2328
{"name": "activeOpacity", "type": "number", "description": "The active opacity when pressing a tab"},
29+
{
30+
"name": "backgroundColor",
31+
"type": "string",
32+
"description": " Apply background color for the tab bar item"
33+
},
2434
{
2535
"name": "activeBackgroundColor",
2636
"type": "string",
@@ -29,7 +39,5 @@
2939
{"name": "style", "type": "ViewStyle", "description": "Pass custom style"},
3040
{"name": "testID", "type": "string", "description": "Used as a testing identifier"}
3141
],
32-
"snippet": [
33-
"<TabBarItem label={$1}/>"
34-
]
42+
"snippet": ["<TabBarItem label={$1}/>"]
3543
}

0 commit comments

Comments
 (0)