Skip to content
Tutorials Center
My learning

Topics

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="".

JSX
<main inert={isModalOpen}>
  ...
</main>

Try it

Freeze a form while it saves
Inert page behind a dialog

Syntax

JSX
<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. disabled applies to form controls only and styles them as disabled. inert applies 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. inert handles both at once.
  • Modal dialogs. A real <dialog> opened with showModal() already makes the rest of the page inert. Use inert yourself 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 inert while 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.