React-native-elements: marginTop on Button creates a shadow in iOS

Created on 30 May 2017  路  3Comments  路  Source: react-native-elements/react-native-elements

Description

  1. Explain what you did
    Added a button and gave it some styles via buttonStyle prop.

<Button title="Onwards!" raised buttonStyle={{ marginTop: 15 }} />

  1. What you expected to happen
    The margin should be added on top of the button.

  2. What actually happens
    Button gets "extended" with a transparent background, but retains border and shadow styles.
    See screenshot below:

screen shot 2017-05-30 at 18 49 01

Also please include the version of react-native-elements that you are using.
0.12.2

Reproduction Steps and Sample Code

We highly recommend that you try to reproduce your bug on https://snack.expo.io/ and provide a link.

If you can't reproduce the bug on Snack, provide an example of your code and briefly explain what the code is suppose to be doing.

Solution

Can you suggest a possible fix that would address this issue? Ideally, you should be able to submit a PR to fix it. See our contributing guide for more details.

Most helpful comment

@hazmah0 Hi, this happens because buttonStyle applies styling to the inner View and since elevation (shadow) is applied to the outer View, this way you basically create a 'padding' in the outer View. Try using containerViewStyle prop instead of buttonStyle. On the other hand I think having the API this way is confusing and I'll try to look into it.

All 3 comments

@hazmah0 Hi, this happens because buttonStyle applies styling to the inner View and since elevation (shadow) is applied to the outer View, this way you basically create a 'padding' in the outer View. Try using containerViewStyle prop instead of buttonStyle. On the other hand I think having the API this way is confusing and I'll try to look into it.

@hazmah0 did @filiphosko's suggestion work for you?

@Monte9, @filiphosko solution worked perfectly!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

binzailani3136 picture binzailani3136  路  3Comments

mikebski picture mikebski  路  3Comments

kubido picture kubido  路  3Comments

iRoachie picture iRoachie  路  3Comments

YikSanChan picture YikSanChan  路  3Comments