When a drawer or side panel is open, the page behind it should stop reacting. For years that meant tabindex="-1" on every link, aria-hidden and a pile of JavaScript. Now it’s one attribute.
<main inert>
...the page behind the drawer...
</main>
<aside class="drawer">...</aside>
According to MDN, an element with inert and everything inside it can’t be focused or clicked, isn’t found by the browser’s find-in-page, doesn’t allow text selection and is removed from the accessibility tree. Tab skips straight over it. MDN lists it as Baseline, available in all major browsers since April 2023.
In JavaScript it’s a boolean property, so opening and closing the drawer is two lines:
document.querySelector("main").inert = true; // drawer opens
document.querySelector("main").inert = false; // drawer closes
For a real modal you don’t even need this: a <dialog> opened with showModal() already handles the rest of the page. inert is for the cases in between, like drawers, a page that’s loading, or a step in a form that isn’t active yet.
Caveat: inert content looks exactly the same as before. MDN says it’s your job to show visually what is active and what isn’t, for example by dimming it. And for one single button, the disabled attribute is the better choice.
Further reading: MDN: inert