-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to add box-shadow for React-native? #709
Comments
Just like normal CSS: https://developer.mozilla.org/de/docs/Web/CSS/box-shadow const BoxShadow = styled.div`
box-shadow: 10px 5px 5px black;
` |
@k15a I forgot to add that this is on react-native |
/cc @jacobp100 we should write some docs specifically for ReactNative on the new website. https://github.com/styled-components/styled-components-website |
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: |
These props are relevant only to iOS right?
Will they work on Android? |
@guysegal they won't since shadows are not supported on RN Android. But you can use elevation |
|
Is this working? Trying to put some shadow on a view with the exact same above code and nothing is happening. |
It only works for iOS IIRC |
We're building React Native for iOS and it's not showing up. |
Does it work with the native |
@ColinFendrick Does this definitely not work for you?
|
Figured out the problem. |
This isn't working for me, I tried to add:
but it gives me the following warning:
|
@jacobp100 Yes! I'd love that ❤️ 😄 |
my emulator is android but the shadow props dont work!!! |
@dakdreams AFAIK android doesn't support shadows. Try elevation:
|
As @jasan-s pointed out, the shadows seem to be on the top instead of the bottom of the View. Any way around this? |
I tried this but I have some text inside the view and it make the text have shadow too, any way around this? |
I just tried wrapping a scrollview with text in a view styled with shadow props, but as @Nemesis30G said the shadow actually applied to the text inside the scrollview as well as the borders of the view. |
Set a background colour on the scrollview |
This is different than CSS style. |
Inset is not working. |
|
The issue with shadowOffset should be documented a little bit better. The only way to work with shadowOffset on React Native was by using the shorthand property |
elevation:4, Dont forget to put margin and padding efficiently as the shadows wont fall out of the container view in android.. However in iOS it shudn't be an issue |
So is anybody going to answer why shadows are appearing on top on IOS, no matter what the shadowOffset properties, as @jasan-s pointed out? |
This comment has been minimized.
This comment has been minimized.
all above solutions doesn't worked in android but this works!!! 😃 |
what is this syntax @k15a
|
This seems to be working fine for me: const IconImage = styled.Image`
height: 30px;
width: 30px;
shadow-color: #000;
shadow-offset: 1px 1px;
shadow-opacity: 0.5;
shadow-radius: 2px;
`; |
Hi is there a solution for this ? All my inner view elements ( text , image ) are also havings shadows |
thanks |
in essence:
The text was updated successfully, but these errors were encountered: