useFocusTrap

Keep the focus inside an element while it is active, cycling with Tab.

This is custom React hooks, you need to follow the Basic Rules when you use it.

General

Press Tab inside the box, the focus never leaves it.

APIs

useFocusTrap

const useFocusTrap = <T extends HTMLElement = HTMLElement>(
  active?: boolean,
) => RefObject<T | null>
Edit this page on GitHub