I am trying to implement box inner shadow similar to what you can achieve using box-shadow:inset in CSS. I tried the following, but I can't get it the shadow more prominent and darker. https://rnplay.org/apps/EHvL4g
var styles = StyleSheet.create({
container: {
flex: 1,
},
box: {
margin: 20,
flex: 1,
backgroundColor: 'transparent',
borderColor: 'white',
borderWidth: 1,
overflow: 'hidden',
shadowColor: 'black',
shadowRadius: 10,
shadowOpacity: 1,
},
});
For styling the Box Shadow in React Native, only the elevation feature is supported in the Android platform, while in the iOS platform, we can style the box-shadow in many ways by setting the opacity, color, height, width, radius, etc.
To set elevation shadow only on the bottom on React Native, we wrap out View with another View and set its overflow to 'hidden' . to set overflow to 'hidden' on the outer View . And then we add the shadow styles in the inner view to add the shadow. elevation is needed for Android to show the shadow.
Increase the borderWidth.
box: {
margin: 10,
flex: 1,
backgroundColor: 'transparent',
borderColor: 'white',
borderWidth: 30,
overflow: 'hidden',
shadowColor: 'black',
shadowRadius: 10,
shadowOpacity: 1,
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With