October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

Why Use a React Portal for a Modal? Escaping Clipped Layouts

A React portal can move a modal beyond a clipping ancestor, but context and React event propagation still follow the React tree. Focus, keyboard, naming, and background behavior remain your responsibility.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A React portal moves a modal to a different place in the DOM, which can let it escape an ancestor that clips or constrains it. It does not remove the modal from its React parent: context and React event propagation still follow the React tree. And a portal only changes placement—it does not provide modal accessibility behavior.

Why is my modal getting clipped?

A modal rendered inside a layout container may be affected by that container’s CSS. For example, an ancestor with overflow: hidden can clip content that extends beyond its bounds. Rendering the modal elsewhere in the DOM can let it appear over the rest of the page. React describes this as one use for createPortal: React’s createPortal reference.

As an Amazon Associate I earn from qualifying purchases.

What does a portal change—and what stays the same?

createPortal(children, domNode, key?) renders its children into the supplied DOM node. That target node must already exist. The portal changes the children’s physical DOM location, not their place in the React tree.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • DOM placement changes: the content becomes a child of the supplied DOM node, rather than being placed under its usual DOM parent.
  • React relationships remain: the content can still use context from its React ancestors, and its React events propagate through the React tree.

This difference matters when a React parent has a click handler even though it is not a DOM ancestor of the portaled content. A click inside the portal can still invoke that parent’s React handler. React documents two ways to address an unwanted propagation: stop propagation inside the portal, or move the portal higher in the React tree. See the React createPortal reference.

#1 Best Overall
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents

How do I render a modal through a portal?

Create or identify a DOM node outside the disruptive container, then pass that node as the portal target. The target must exist when the portal is rendered.

import { createPortal } from 'react-dom';

function Modal({ children }) {
  const target = document.getElementById('modal-root');

  if (!target) return null;

  return createPortal(children, target);
}

For example, the page can provide a target outside the application area that clips the modal:

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
<div id="app-root"><!-- React application --></div>
<div id="modal-root"></div>

The example handles a missing target by rendering nothing. In an application where the target is required, choose a deliberate failure or loading strategy instead of silently hiding an expected dialog. A portal changes placement; it does not decide when the modal opens, how it closes, or how users interact with it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What accessibility behavior must a modal provide?

The WAI-ARIA Authoring Practices Guide’s Dialog (Modal) Pattern treats interaction as a separate responsibility from rendering the dialog elsewhere in the DOM.

Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.
  • Move focus into the dialog when it opens. The WAI-ARIA pattern states: “When a dialog opens, focus moves to an element inside the dialog.”
  • Keep keyboard focus within it. Tab and Shift+Tab should stay within the dialog’s tab sequence while it is open.
  • Provide a keyboard close path. The pattern specifies that Escape closes the dialog.
  • Give the dialog an accessible name. Use a visible title referenced by aria-labelledby, or provide an aria-label.
  • Make the background genuinely unavailable. Mark a dialog modal only if the rest of the page is obscured and interaction with it is prevented. aria-modal declares semantics; it does not itself block background interaction.

For a long or structurally rich dialog, the WAI-ARIA pattern advises considering initial focus on a static element near the beginning instead of automatically focusing the first interactive control. It also cautions against using aria-describedby when that would make complex structured content be announced as one unbroken string.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Is a portal enough to make a modal?

No. A portal can solve a DOM placement problem, such as clipping by an ancestor, while retaining the modal’s React context and event relationships. The modal still needs appropriate focus handling, keyboard behavior, an accessible name, and a background that is actually unavailable to interaction when it is declared modal. React’s guidance is to “Follow the WAI-ARIA Modal Authoring Practices when creating modals.” Read the React createPortal documentation alongside the WAI-ARIA modal dialog pattern.

Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
Rank #4
Sale
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor | 100Hz, Game Mode, Advanced Eye Comfort, HDMI and D-sub Ports (LS27D366GANXZA)
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.