use-focus-trap traps focus at the given node, for example in modal, drawer or menu.
Node must include at least one focusable element. When the node unmounts, the focus trap is automatically released.
The hook accepts focus trap active state as a single argument:
The hook returns
ref that should be passed to the element:
use-focus-trap with other ref based hooks, use use-merged-ref hook:
By default, focus trap will move focus to the first interactive element.
To specify the element that should receive initial focus, add