@lexical/react/useLexicalFocusTrap
Functions
useLexicalFocusTrap()
useLexicalFocusTrap(
containerRef,isActive,initialFocus?):void
Defined in: packages/lexical-react/src/useLexicalFocusTrap.ts:26
React wrapper around registerFocusTrap from @lexical/a11y.
Traps Tab / Shift+Tab focus inside containerRef while isActive is
true, and restores focus to the previously-focused element when the
trap deactivates. Intended for modal dialogs and other transient
overlays.
initialFocus is expected to stay stable for the lifetime of the
trap. See registerFocusTrap JSDoc for the trap's caveats (portal
descendants, single-trap requirement).
Parameters
containerRef
RefObject<HTMLElement | null>
isActive
boolean
initialFocus?
FocusTrapInitialFocus = 'firstFocusable'
Returns
void
References
FocusTrapInitialFocus
Re-exports FocusTrapInitialFocus