Portals for Modals, Tooltips, and Overlays (Applied)
Learn the practical application of Portals to build correctly-layered, accessible modal and overlay components.
Building on the general Portal mechanism, real-world modal and overlay components need to combine createPortal with careful attention to focus management, keyboard interaction, and z-index/stacking, not just the physical DOM placement itself. A production-quality modal traps focus within itself while open (so Tab doesn't cycle focus to elements behind it), restores focus to whatever triggered it on close, and closes on Escape key press.
A well-built modal is like a temporary interview room set up mid-office (via Portal), but a good facilities team also makes sure the door locks properly while in use (focus trap), reopens automatically to the hallway once you leave (focus restoration), and has a clear exit sign and emergency release (Escape key and accessible labeling) — not just a room that happens to physically exist somewhere convenient.