Usage of zIndex property
See original GitHub issueIn pure Konva
framework, we have zIndex
property. It is very useful to change order of elements with that property:
node.setZIndex(2);
In react-konva
the order of elements will be defined as it is defined in render()
function of a component:
// Rect will have zIndex = 0
// Circle will have zIndex = 1
const Component = () =>
<Group>
<Rect>
<Circle>
<Group>
// Rect will have zIndex = 1
// Circle will have zIndex = 0
const Component2 = () =>
<Group>
<Circle>
<Rect>
<Group>
We may have unexpected result if we will use two logics of ordering at the same time:
const Component = () =>
<Group>
<Rect zIndex={1}>
<Circle>
<Group>
So my suggestion is to NOT use zIndex
attrube in react-konva
. Just reorder nodes in render().
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
CSS z-index property - W3Schools
The z-index property specifies the stack order of an element. An element with greater stack order is always in front of an element...
Read more >Using z-index - CSS: Cascading Style Sheets - MDN Web Docs
When no z-index property is specified, elements are rendered on the default rendering layer (Layer 0). · If several elements share the same...
Read more >z-index - CSS-Tricks
The z-index property in CSS controls the vertical stacking order of elements that overlap. As in, which one appears as if it is...
Read more >The Z-Index CSS Property: A Comprehensive Look
The z-index property determines the stack level of an HTML element. The “stack level” refers to the element's position on the Z axis...
Read more >Z Index in CSS: What it Is and What it Does - freeCodeCamp
Z Index ( z-index ) is a CSS property that defines the order of overlapping HTML elements. Elements with a higher index will...
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 FreeTop 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
Top GitHub Comments
No, we don’t need to rever the order from
react-konva
side. If you need to revert it, you can do it manually from yourrender()
function.https://konvajs.org/docs/react/zIndex.html