React Reference ยท Props and Attributes
React inert attribute
Reference for the inert attribute in React 19: how inert={true} disables clicks, focus and screen reader access for a subtree, and how it differs from disabled.
inert is a boolean HTML attribute. When an element has it, the element and everything inside it stops being interactive: it cannot be clicked, cannot be focused or tabbed to, cannot be selected, and is hidden from assistive technology. Visually nothing changes unless you style it.
That makes inert ideal for modal layouts (the page behind an open dialog), for a section that is still loading, and for off-screen panels that must not be reachable by keyboard. React 19 understands inert as a real boolean: inert={true} writes the attribute and inert={false} leaves it out. Earlier React versions required the string workaround inert="".
<main inert={isModalOpen}> ... </main>
Try it
Syntax
<element inert /> <element inert={boolean} />
| Name | Description |
|---|---|
inert |
true adds the attribute and makes the element and its descendants inert. false, undefined and null omit it. |
Returns: nothing; it is an attribute. The DOM property is element.inert.
Edge cases: do not pass the string "false"; any non-empty string is truthy. Passing a string "" also works but is a legacy habit.
Usage notes
- Whole subtree. Inertness cannot be undone for a child. A descendant cannot opt out of an inert ancestor.
- Not the same as
disabled.disabledapplies to form controls only and styles them as disabled.inertapplies to any element, makes text unselectable and removes the subtree from the accessibility tree. It does not change appearance, so add styling (such as lower opacity) if the user should see that the area is frozen. - Not the same as
aria-hidden.aria-hidden="true"hides content from screen readers but leaves it focusable, which is an accessibility bug.inerthandles both at once. - Modal dialogs. A real
<dialog>opened withshowModal()already makes the rest of the page inert. Useinertyourself for custom overlays, drawers and side panels. - Off-screen content. A menu that slides away with a CSS transform is still in the tab order. Mark it
inertwhile closed. - Find in page. Text inside an inert subtree is not matched by the browser's find feature.
- Focus management. If the focused element becomes inert, focus moves to the document body. Move focus deliberately (to the dialog, for example) when you set
inert. - Support. Part of Baseline and available in all current browsers. React 19 knows the attribute; with React 18 pass
inert=""or set it in an effect.