document.body
The page's <body> element as seen from JavaScript, the usual target for portals and the fallback when focus is lost.
In more detail
When a focused element is removed, focus falls back to document.body and keyboard users lose their place. Scroll locking also sets overflow on it.
Related terms
- portal — A React feature, createPortal, that renders a component's children into a different place in the DOM, usually document.body.
- focus restoration — Returning keyboard focus to the element that opened an overlay, such as its trigger button, when the overlay closes.
- scroll locking — Stopping the page behind an overlay from scrolling, usually by setting overflow: hidden on the body while the overlay is open.
Taught in
- Overlay Architecture: Portals, Stacking Contexts & Backdrops — Design Systems & Component Engineering
- Focus Management: Trapping, Restoration & Focus Rings — Design Systems & Component Engineering