Releases the focus trap, so that every element on the page is reachable by Tab again.
Call it from browser code when the dialog, popup, or menu that set the trap closes, and when its component unmounts while it's open. It has no effect while the page renders on the server.
There's one trap for the whole page, so the method releases it whichever component set it. It does nothing when there's no trap, so calling it twice is safe.
When it releases the trap, the method:
tabindex that each element had before the trap, overwriting any tabindex your code
set on it while the trap was on.Traps keyboard focus in the specified containers, so that Tab and Shift+Tab reach only elements inside them.
Call it when a dialog, popup, or menu opens over the page, so that site visitors using a keyboard can't reach controls hidden behind it.
It takes the following elements outside the containers out of the Tab order: buttons, form fields,
iframes, links with an href, and elements with a tabindex. Other focusable elements, such as
contenteditable regions, media controls, and anything inside a shadow root, stay reachable.
Call it from browser code, such as an event handler or an effect, once the containers are on the page, because:
The method doesn't move focus, so move focus to an element inside a container yourself.
There's one trap for the whole page, so each call replaces the current trap rather than adding to it.
To release the trap, call reset().
Values of the container elements' id attributes.
Last updated: 21 October 2026