IOS - zIndex ignored with nested views
See original GitHub issueFollowing code does not work as expected on IOS simulator with RN 0.30.0. On android it seems to work correctly.
import React, { Component } from 'react';
import { StyleSheet, Text, View } from 'react-native';
export default class Demo extends Component {
render() {
return (
<View style={styles.container}>
<View>
<View style={[styles.blueItem, {zIndex: 100}]}>
<Text>zIndex: 100</Text>
</View>
</View>
<View style={[styles.greenItem, styles.absolute, {zIndex: 2}]}>
<Text>zIndex: 2</Text>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
paddingTop: 20,
},
blueItem: {
backgroundColor: 'blue',
height: 50,
},
greenItem: {
backgroundColor: 'green',
height: 50,
width: 50,
position: 'absolute',
top: 45,
left: 0,
},
});
I would expect that blue item with zIndex 100 will be over green box (with zIndex 2).

Note that if I remove the “outer view” (around blue box), zIndex works fine.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:8
- Comments:13 (6 by maintainers)
Top Results From Across the Web
zIndex not working properly in react-native in IOS
In iOS, the zIndex doesn't work for nested parentView. You need to make the parentView has high zIndex, and then target View again....
Read more >Stacking overlapping views with zIndex in Expo and React ...
Learn how to stack overlapping views with zIndex. zIndex is the Expo and React Native analog of CSS's z-index property which lets the...
Read more >iOS : zIndex not working properly in react-native in IOS
iOS : zIndex not working properly in react-native in IOS [ Beautify Your Computer : https://www.hows.tech/p/recommended.html ] iOS : zIndex ...
Read more >CSS Z-Index Not Working? How to Fix It Using Stack Order
So in this post, I'm going to explain what the z-index property is, what stacking order is, and how to use them in...
Read more >Using methods like zIndex in React Native to stack elements
When two or more React Native elements overlap, their zIndex values will determine where they'll be placed in the stack. The element with...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The browser makes some performance tradeoffs, and has significant added layout complexity in every other part of the layout system, in order to be able to implement z-index to spec. I’m not sure this is something react-native wants/needs, especially since most problems related to z-index can be solved in another way.
What is your specific issue @singno?
Also every item starts at zIndex: 0 I believe, basically that means that stacking contexts as defined in WC3 isn’t really implemented to spec (for performance and complexity reasons). What you get with this new zIndex system is resolving sibling view display order independent of their order in code. I’m not sure it’s much more than that, though I might be wrong, would be good to get some opinion from a core member.
Tagging @vjeux because I know he cares about web spec compatibility,