Tree of DesignAll terms A–Z

Focus Trap

Keeping keyboard focus inside a dialog until it closes.

See it on the 3D tree

Going deeper

While a modal dialog is open, tabbing cycles within it instead of reaching the page behind. Focus moves into it on opening, Escape or a close button dismisses it, and focus usually returns to the control that opened it. A trap with no keyboard exit is an accessibility failure.

Why it matters

It keeps keyboard focus off the page behind while still letting people leave; screen readers also need that page made inert.

In practice

A confirmation dialog opens with focus on its safe option, and tabbing moves only between its buttons.

Common mistake

Trapping focus but forgetting to return it afterwards, leaving users at the top of the page.

Connected terms