Skip to content

Commit

Permalink
feat(breaking): create tabBarStyle (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
szymonrybczak authored Jan 15, 2025
1 parent e83e0f2 commit e01445f
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .changeset/rare-berries-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'react-native-bottom-tabs': minor
---

feat!: add tabBarStyle, remove barTintColor prop
6 changes: 3 additions & 3 deletions apps/example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ const FourTabsOpaqueScrollEdgeAppearance = () => {
return <FourTabs scrollEdgeAppearance="opaque" />;
};

const FourTabsWithBarTintColor = () => {
return <FourTabs barTintColor={'#87CEEB'} />;
const FourTabsWithBackgroundColor = () => {
return <FourTabs backgroundColor={'#87CEEB'} />;
};

const FourTabsTranslucent = () => {
Expand Down Expand Up @@ -108,7 +108,7 @@ const examples = [
platform: 'ios',
},
{
component: FourTabsWithBarTintColor,
component: FourTabsWithBackgroundColor,
name: 'Four Tabs - Custom Background Color of Tabs',
},
{
Expand Down
6 changes: 3 additions & 3 deletions apps/example/src/Examples/FourTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface Props {
ignoresTopSafeArea?: boolean;
disablePageAnimations?: boolean;
scrollEdgeAppearance?: 'default' | 'opaque' | 'transparent';
barTintColor?: ColorValue;
backgroundColor?: ColorValue;
translucent?: boolean;
hideOneTab?: boolean;
rippleColor?: ColorValue;
Expand All @@ -21,7 +21,7 @@ export default function FourTabs({
ignoresTopSafeArea = false,
disablePageAnimations = false,
scrollEdgeAppearance = 'default',
barTintColor,
backgroundColor,
translucent = true,
hideOneTab = false,
rippleColor,
Expand Down Expand Up @@ -71,7 +71,7 @@ export default function FourTabs({
navigationState={{ index, routes }}
onIndexChange={setIndex}
renderScene={renderScene}
barTintColor={barTintColor}
tabBarStyle={{ backgroundColor }}
translucent={translucent}
rippleColor={rippleColor}
activeIndicatorColor={activeIndicatorColor}
Expand Down
4 changes: 3 additions & 1 deletion apps/example/src/Examples/NativeBottomTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ function NativeBottomTabs() {
hapticFeedbackEnabled={false}
tabBarInactiveTintColor="#C57B57"
tabBarActiveTintColor="#F7DBA7"
barTintColor="#1E2D2F"
tabBarStyle={{
backgroundColor: '#1E2D2F',
}}
rippleColor="#F7DBA7"
tabLabelStyle={{
fontFamily: 'Avenir',
Expand Down
10 changes: 7 additions & 3 deletions docs/docs/docs/guides/standalone-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,16 @@ Color for the active tab.
#### `tabBarInactiveTintColor`

Color for inactive tabs.

- Type: `ColorValue`

#### `barTintColor`
#### `tabBarStyle`

Background color of the tab bar.
- Type: `ColorValue`
Object containing styles for the tab bar.

Supported properties:

- `backgroundColor`: Background color of the tab bar.

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

Expand Down
9 changes: 7 additions & 2 deletions docs/docs/docs/guides/usage-with-react-navigation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ It supports the following values:
#### `labeled`

Whether to show labels in tabs.

- Type: `boolean`
- Default <Badge text="iOS" type="info" />: `true`
- Default <Badge text="Android" type="info" />: `false`
Expand Down Expand Up @@ -130,9 +131,13 @@ Color for the active tab.

Color for the inactive tabs.

#### `barTintColor`
#### `tabBarStyle`

Object containing styles for the tab bar.

Supported properties:

Background color of the tab bar.
- `backgroundColor`: Background color of the tab bar.

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

Expand Down
15 changes: 9 additions & 6 deletions packages/react-native-bottom-tabs/src/TabView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,13 @@ interface Props<Route extends BaseRoute> {
*/
getTestID?: (props: { route: Route }) => string | undefined;

/**
* Background color of the tab bar.
*/
barTintColor?: ColorValue;
tabBarStyle?: {
/**
* Background color of the tab bar.
*/
backgroundColor?: ColorValue;
};

/**
* A Boolean value that indicates whether the tab bar is translucent. (iOS only)
*/
Expand Down Expand Up @@ -166,10 +169,10 @@ const TabView = <Route extends BaseRoute>({
? route.focusedIcon
: route.unfocusedIcon
: route.focusedIcon,
barTintColor,
getHidden = ({ route }: { route: Route }) => route.hidden,
getActiveTintColor = ({ route }: { route: Route }) => route.activeTintColor,
getTestID = ({ route }: { route: Route }) => route.testID,
tabBarStyle,
hapticFeedbackEnabled = false,
tabLabelStyle,
...props
Expand Down Expand Up @@ -290,7 +293,7 @@ const TabView = <Route extends BaseRoute>({
hapticFeedbackEnabled={hapticFeedbackEnabled}
activeTintColor={activeTintColor}
inactiveTintColor={inactiveTintColor}
barTintColor={barTintColor}
barTintColor={tabBarStyle?.backgroundColor}
rippleColor={rippleColor}
>
{trimmedRoutes.map((route) => {
Expand Down

0 comments on commit e01445f

Please sign in to comment.