Missing tabbar shadow on Android
Current Behavior
I'm not seeing an elevation shadow under my tabbar on Android. I've tried using elevation as style property.
tabBarOptions: {
activeTintColor: AppStyles.color.secondary,
inactiveTintColor: Platform.OS === 'ios' ? '#BBBBBB' : '#000000',
upperCaseLabel: false,
showIcon: true,
indicatorStyle: { opacity: 0 },
labelStyle: {
fontFamily: AppStyles.fontFamily.medium,
fontSize: AppStyles.fontSize.small,
marginBottom: 8
},
style: {
paddingTop: 4,
backgroundColor: '#fff',
height: 57,
...Platform.select({
android: {
elevation: 3
}
})
}
},
Expected Behavior
I'd expect to see a drop shadow behind my tabbar based on elevation value.
Your Environment
| software | version |
|---|---|
| react-navigation | 1.0.0-beta.11 |
| react-native | 0.43.2 |
| node | |
| npm or yarn |
Can you sent us a screenshot?
Do you use a StackNavigator into a TabNavigator ?
Current rendering on Android:

Desired effect:

The TabNavigator is inside a StackNavigator.
Hi, i have the same issue. Any ideas to fix this? My TabNavigator is the Root navigator.
I have another problem, on iOS I am trying to remove this top shadow and I cannot do that, anyone managed to do this ?
+1 having the same issue for "normal" tab screens aswell as tab screens which are themselves StackNavigators
Vou ficar esperando uma resposta também, no meu caso o TabBar é Top (padrão android), mas isso é o de menos.
try:
tabBarOptions: {
style: {
elevation: 4,
marginBottom: 5
}
}
None is working for me. I tried elevation in both style and tabStyle. None was helpful.
Hi! In an effort to get the hundreds of issues on this repo under control I'm closing issues tagged as questions. Please don't take this personally - it's simply something we need to do to get the issues to a manageable point. If you still have a question I encourage you to re-read the docs, ask on StackOverflow, or ask on the #react-navigation Reactiflux channel. Thank you!
This is what worked for me.
tabBarOptions: {
style: {
paddingBottom: 2,
}
}
I know the look isn't the same as a shadow, but for me this worked better.
Any update regarding this, I am using 0.48 and elevation is not working?
Elevation is mostly a bottom-shadow. Try this
tabBarOptions: {
style: {
borderTopWidth: 0,
elevation: 8
}
}
Hi, nothing here worked for me so I created a component to simulated a shadow with react-native-linear-gradient and I putted it in top of the tabBar component (I created a custom tab bar)
Here is the code for the shadow component, it's pretty easy:
import { StyleSheet } from 'react-native';
import LinearGradient from 'react-native-linear-gradient';
import { colors } from '../../config/colors';
const ShadowTabBar = () => (
<LinearGradient
start={{ x: 1, y: 0 }} // for a vertical gradient
end={{ x: 1, y: 1 }} // for a vertical gradient
locations={[0, 0.3, 1]} // 3 "steps" of color
colors={['#ededed', '#e2e2e2', '#c6c6c6']} // top color, middle color, bottom color
style={styles.gradient}
/>
);
const styles = StyleSheet.create({
gradient: {
height: 3
}
});
export default ShadowTabBar;
And here is the code for the custom tab bar:
import React, { Component } from 'react';
import { View, StyleSheet, TouchableWithoutFeedback } from 'react-native';
import PartyNowGradient from '../components/common/PartyNowGradient';
import ShadowTabBar from '../components/tab_bar/ShadowTabBar';
import { colors } from '../config/colors';
class CustomTabBar extends Component {
render() {
const {
navigation,
renderIcon,
activeTintColor,
inactiveTintColor,
jumpToIndex
} = this.props;
const {
routes
} = navigation.state;
return (
<View>
<ShadowTabBar />
<View style={styles.tabBar}>
{routes && routes.map((route, index) => {
const focused = index === navigation.state.index;
const tintColor = focused ? activeTintColor : inactiveTintColor;
return (
<TouchableWithoutFeedback
key={route.key}
style={styles.tab}
onPress={() => jumpToIndex(index)}
>
<View style={styles.tab}>
{renderIcon({
route,
index,
focused,
tintColor
})}
</View>
</TouchableWithoutFeedback>
);
})}
</View>
</View>
);
}
}
const styles = StyleSheet.create({
tabBar: {
height: 45,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
backgroundColor: "white",
borderRadius: 3
},
tab: {
alignSelf: 'stretch',
flex: 1,
alignItems: 'center',
justifyContent: 'center',
}
});
export default CustomTabBar;
@zygama Can i see your preview UI with that code?
tabBarOptions: { style: { elevation: 0 } } worked for me
If it is still relevant for you:
tabBarOptions: {
showLabel: false,
style: {
backgroundColor: colors.light[3],
elevation: 5,
borderTopWidth: 2,
top: 1, // This is the important part.. without it there will be no shadow effect on the top edge of the tab bar.
},
},
I had the same issue and turns out that it is because of style prop of screens of tabs. I had used backgroundColor in my components, so they covered the shadow of the tab bar. I removed backgroundColor and shadow appeared.
Is it possible to add offset for shadow on android?
@omerman do you have a working example? top: 1 does not have any effect for me, I just get a shadow at the bottom of the tabbar, which is obviously not visible for a bottom tab bar
top: 10 will move your tab buttons down and you will see the shadow over some other ui component beneath which actually hides it when top is 0.