React-native: Background color visible through the border of a border radius

Created on 17 Apr 2015  路  10Comments  路  Source: facebook/react-native

When a <View /> component uses backgroundColor and borderRadius, the background color is still visible over the edges of the border.

Screenshot:
reactnative-borderradiusbug

Example code:

var MyComponent = React.createClass({
  render() {
    return <View style={styles.example} />
  }
});

var styles = StyleSheet.create({
  example: {
    backgroundColor: 'white',
    borderRadius: 16,
    borderWidth: 1,
    borderColor: 'black'
  }
});
Locked

Most helpful comment

Hi there! Try setting overflow: hidden, does that fix it?

All 10 comments

Hi there! Try setting overflow: hidden, does that fix it?

@frostney - does this still occur on 0.4.0 for you?

screen shot 2015-04-18 at 4 04 01 pm

I can only reproduce this when I have some other item inside, eg: , which inherits the background colour of the parent by default and does not have border radius and so it appears to be outside of the rounded corner. You will have to use overflow: hidden as mentioned above to fix that issue.

overflow: hidden does fix it for me. Thank you.
I hope it's ok that I'm closing this issue.

Edit: The code example is more stripped down than I intended it to be. This issue occured for me on views (with borderRadius and backgroundColor) that had texts and views as its children (those were without background color or borderRadius) and when I created the code example I forgot to copy over the hierarchy from the production code to the example code while making a screenshot from the production code. Sorry about that.

@frostney - no problem, glad it helped! :smile:

overflow: 'hidden' does fix it for me too.

Thats not the expected css behaviour. Maybe we should write it in the docs.

Greetings

I believe this now works correctly.

I still have this issue but only with absolutely positioned views. The overflow: 'hidden' works for me as well.

It is still an issue but overflow: 'hidden' works. Thanks.

The issue with overflow is you can't use shadows anymore as they are considered as overflowing elements.

as @uandco mentioned, the overflow cannot be used together with shadow properties.. What is the workaround here?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

madwed picture madwed  路  3Comments

grabbou picture grabbou  路  3Comments

jlongster picture jlongster  路  3Comments

anchetaWern picture anchetaWern  路  3Comments

josev55 picture josev55  路  3Comments