Chapter 13 · Example 3 · React portals and why do we need them

z-index and stacking context

Adding position and z-index to a parent div creates an isolated stacking context, so the trapped dialog stays under a sibling no matter how high its own z-index goes.

Loading live editor…