portal
A React feature, createPortal, that renders a component's children into a different place in the DOM, usually document.body.
In more detail
Portals let overlays escape parents that clip them with overflow: hidden or trap them in a stacking context. The portaled content still belongs to the same React tree, so context values and event bubbling work as if it had stayed in place.
Example
createPortal(<aside>{children}</aside>, document.body)Related terms
- overlay — Any piece of interface that appears on top of the page, such as a modal dialog, popover, tooltip, menu or toast.
- 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.
- event bubbling — The way an event on an element also triggers handlers on its parent elements, one level at a time up the tree.
- React Context — A React feature that lets a parent component make a value available to every component below it without passing it as props.
- modal dialog — A window laid over the page that users must deal with before returning to the page beneath, with role="dialog" and aria-modal="true".
Taught in
- Overlay Architecture: Portals, Stacking Contexts & Backdrops — Design Systems & Component Engineering
- Modal Dialogs & Alert Dialogs: Accessible Overlay Patterns — 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