Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
*/
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 @@
? 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 @@ -201,7 +204,7 @@

if (!loaded.includes(focusedKey)) {
// Set the current tab to be loaded if it was not loaded before
setLoaded((loaded) => [...loaded, focusedKey]);

Check warning on line 207 in packages/react-native-bottom-tabs/src/TabView.tsx

View workflow job for this annotation

GitHub Actions / lint

'loaded' is already declared in the upper scope on line 203 column 10
}

const icons = React.useMemo(
Expand Down Expand Up @@ -290,7 +293,7 @@
hapticFeedbackEnabled={hapticFeedbackEnabled}
activeTintColor={activeTintColor}
inactiveTintColor={inactiveTintColor}
barTintColor={barTintColor}
barTintColor={tabBarStyle?.backgroundColor}
rippleColor={rippleColor}
>
{trimmedRoutes.map((route) => {
Expand Down
Loading