Skip to content
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

Background color visible through the border of a border radius #904

Closed
frostney opened this issue Apr 17, 2015 · 10 comments
Closed

Background color visible through the border of a border radius #904

frostney opened this issue Apr 17, 2015 · 10 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@frostney
Copy link
Contributor

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'
  }
});
@brentvatne
Copy link
Collaborator

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

@brentvatne
Copy link
Collaborator

@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.

@frostney
Copy link
Contributor Author

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.

@brentvatne
Copy link
Collaborator

@frostney - no problem, glad it helped! 😄

@ms88privat
Copy link

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

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

Greetings

@nicklockwood
Copy link
Contributor

I believe this now works correctly.

@zebulgar
Copy link

zebulgar commented Mar 3, 2016

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

@BGuven
Copy link

BGuven commented Apr 11, 2016

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

@uandco
Copy link

uandco commented Apr 27, 2017

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

@anceque
Copy link

anceque commented Jun 15, 2017

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

@facebook facebook locked as resolved and limited conversation to collaborators May 29, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

9 participants