diff --git a/.changeset/rare-berries-rush.md b/.changeset/rare-berries-rush.md new file mode 100644 index 00000000..4ce47a4c --- /dev/null +++ b/.changeset/rare-berries-rush.md @@ -0,0 +1,5 @@ +--- +'react-native-bottom-tabs': minor +--- + +feat!: add tabBarStyle, remove barTintColor prop diff --git a/apps/example/src/App.tsx b/apps/example/src/App.tsx index b724fb26..f4a42d55 100644 --- a/apps/example/src/App.tsx +++ b/apps/example/src/App.tsx @@ -52,8 +52,8 @@ const FourTabsOpaqueScrollEdgeAppearance = () => { return ; }; -const FourTabsWithBarTintColor = () => { - return ; +const FourTabsWithBackgroundColor = () => { + return ; }; const FourTabsTranslucent = () => { @@ -108,7 +108,7 @@ const examples = [ platform: 'ios', }, { - component: FourTabsWithBarTintColor, + component: FourTabsWithBackgroundColor, name: 'Four Tabs - Custom Background Color of Tabs', }, { diff --git a/apps/example/src/Examples/FourTabs.tsx b/apps/example/src/Examples/FourTabs.tsx index ed09bfc3..6c2fc4f8 100644 --- a/apps/example/src/Examples/FourTabs.tsx +++ b/apps/example/src/Examples/FourTabs.tsx @@ -10,7 +10,7 @@ interface Props { ignoresTopSafeArea?: boolean; disablePageAnimations?: boolean; scrollEdgeAppearance?: 'default' | 'opaque' | 'transparent'; - barTintColor?: ColorValue; + backgroundColor?: ColorValue; translucent?: boolean; hideOneTab?: boolean; rippleColor?: ColorValue; @@ -21,7 +21,7 @@ export default function FourTabs({ ignoresTopSafeArea = false, disablePageAnimations = false, scrollEdgeAppearance = 'default', - barTintColor, + backgroundColor, translucent = true, hideOneTab = false, rippleColor, @@ -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} diff --git a/apps/example/src/Examples/NativeBottomTabs.tsx b/apps/example/src/Examples/NativeBottomTabs.tsx index 23d63873..b5b81f60 100644 --- a/apps/example/src/Examples/NativeBottomTabs.tsx +++ b/apps/example/src/Examples/NativeBottomTabs.tsx @@ -15,7 +15,9 @@ function NativeBottomTabs() { hapticFeedbackEnabled={false} tabBarInactiveTintColor="#C57B57" tabBarActiveTintColor="#F7DBA7" - barTintColor="#1E2D2F" + tabBarStyle={{ + backgroundColor: '#1E2D2F', + }} rippleColor="#F7DBA7" tabLabelStyle={{ fontFamily: 'Avenir', diff --git a/docs/docs/docs/guides/standalone-usage.md b/docs/docs/docs/guides/standalone-usage.md index 5f6fb1bb..37878bc8 100644 --- a/docs/docs/docs/guides/standalone-usage.md +++ b/docs/docs/docs/guides/standalone-usage.md @@ -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` diff --git a/docs/docs/docs/guides/usage-with-react-navigation.mdx b/docs/docs/docs/guides/usage-with-react-navigation.mdx index 10f0dc86..f4e8c3a9 100644 --- a/docs/docs/docs/guides/usage-with-react-navigation.mdx +++ b/docs/docs/docs/guides/usage-with-react-navigation.mdx @@ -96,6 +96,7 @@ It supports the following values: #### `labeled` Whether to show labels in tabs. + - Type: `boolean` - Default : `true` - Default : `false` @@ -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` diff --git a/packages/react-native-bottom-tabs/src/TabView.tsx b/packages/react-native-bottom-tabs/src/TabView.tsx index 7f56420f..9fb9a324 100644 --- a/packages/react-native-bottom-tabs/src/TabView.tsx +++ b/packages/react-native-bottom-tabs/src/TabView.tsx @@ -116,10 +116,13 @@ interface Props { */ 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) */ @@ -166,10 +169,10 @@ const TabView = ({ ? 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 @@ -290,7 +293,7 @@ const TabView = ({ hapticFeedbackEnabled={hapticFeedbackEnabled} activeTintColor={activeTintColor} inactiveTintColor={inactiveTintColor} - barTintColor={barTintColor} + barTintColor={tabBarStyle?.backgroundColor} rippleColor={rippleColor} > {trimmedRoutes.map((route) => {