Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

box-shadow:inset for react-native

Tags:

react-native

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,
    },
});
like image 664
Brackets Avatar asked Jun 28 '16 18:06

Brackets


People also ask

Is there box shadow in React Native?

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.

How do you set the bottom shadow in React Native?

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.


1 Answers

Increase the borderWidth.

box: {
margin: 10,
flex: 1,
backgroundColor: 'transparent',
borderColor: 'white',
borderWidth: 30,
overflow: 'hidden',
shadowColor: 'black',
shadowRadius: 10,
shadowOpacity: 1,
}

enter image description here

like image 144
csath Avatar answered Sep 28 '22 03:09

csath