question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to add box-shadow for React-native?

See original GitHub issue

in essence:

shadowOffset:{  width: 10,  height: 10,  },
shadowColor: 'black',
shadowOpacity: 1.0,

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:48
  • Comments:37 (12 by maintainers)

github_iconTop GitHub Comments

324reactions
k15acommented, Apr 19, 2017

Just like normal CSS: https://developer.mozilla.org/de/docs/Web/CSS/box-shadow

const BoxShadow = styled.div`
  box-shadow: 10px 5px 5px black;
`
98reactions
jasan-scommented, Apr 19, 2017

For some reason @k15a @mxstbr the following two give me different results in terms of styling(equivalent property values):

const styles = StyleSheet.create({
  containerStyle: {
    borderWidth: 1,
    borderRadius: 2,
    borderColor: '#ddd',
    borderBottomWidth: 0,
    shadowColor: '#000',
    shadowOffset: { width: 0, height: 2 },
    shadowOpacity: 0.8,
    shadowRadius: 2,
    elevation: 1,
    marginLeft: 5,
    marginRight: 5,
    marginTop: 10,
  }
})
const StyledView = styled.View`
  border-width: 1;
  border-radius: 2;
  border-color: #ddd;
  border-bottom-width: 0;
  shadow-color: #000;
  shadow-offset: {width: 0, height: 2};
  shadow-opacity: 0.8;
  shadow-radius: 2;
  elevation: 1;
  margin-left: 5;
  margin-right: 5;
  margin-top: 10;
`

NOTICE THE DIFFERENT PLACEMENT OF SHADOW using styled-components the shadow is on top:

(With Stylesheet create -- the shadow is on bottom) (With styles-components -- the shadow is on top)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Applying box shadows in React Native - LogRocket Blog
For adding box shadows in Android, we can use the elevation prop, which uses the Android Elevation API. ... Next, import the StyleSheet...
Read more >
Creating a UI with box shadow in react native - Stack Overflow
I added a top and bottom inner box shadow to an image with full width and 140 height. You could create multiple gradients...
Read more >
Shadow Props - React Native
Sets the drop shadow color. This property will only work on Android API 28 and above. For similar functionality on lower Android APIs, ......
Read more >
React Native Shadow Generator - Ether
shadowColor : "#000", shadowOffset: { width: 0, height: 2, }, shadowOpacity: 0.25, shadowRadius: 3.84, elevation: 5,. Android. iOS.
Read more >
How to apply shadows on React Native - Medium
Box shadow · inset: If not specified (default), the shadow is assumed to be a drop shadow (as if the box were raised...
Read more >

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found