stacking context
A group of elements that the browser layers together, so their z-index values only compete with each other and not with the rest of the page.
In more detail
Properties such as transform, filter, opacity below 1 and position with a z-index create a new stacking context. An overlay inside one cannot rise above elements outside it, however high its z-index, which is why overlays are portaled to the body.
Example
That is why React modals are rendered through a portal at the end of the page.Related terms
- z-index — The CSS property that sets which positioned elements appear in front of others.
- portal — A React feature, createPortal, that renders a component's children into a different place in the DOM, usually document.body.
- CSS transform — The CSS property that moves, rotates, scales or skews an element without changing the layout around it.
- CSS — The language that describes how web pages look: colours, fonts, spacing, layout and animation.
- overflow — The CSS property that decides what happens to content that does not fit in its box: show it, clip it or scroll it.
Taught in
- Overlay Architecture: Portals, Stacking Contexts & Backdrops — Design Systems & Component Engineering
- Error Boundaries: componentDidCatch And Fallback UI Trees — React 19 & Modern Component Architecture
- React Portals: Escaping Stacking Contexts for Modals — React 19 & Modern Component Architecture