Traps focus within a specified element.
The HTML element type.
If the focus trap should be active or not
This hook ensures that focus remains within the given element when navigating with the keyboard (Tab/Shift+Tab). It also restores focus to the last focused element within the trap if focus is lost.
const ref = useFocusTrap(true);return <div ref={ref}>...</div>; Copy
const ref = useFocusTrap(true);return <div ref={ref}>...</div>;
Traps focus within a specified element.