UNPKG

@primer/react-brand

Version:

Primer Brand is a GitHub's design system for creating React-based marketing websites and digital experiences.

31 lines 1.62 kB
import React from 'react'; export interface FocusTrapHookSettings<ContainerElement extends HTMLElement = HTMLElement, InitialFocusElement extends HTMLElement = HTMLElement> { /** * Ref object that will be used for the trapping container. If not provided, one will * be created by this hook and returned. */ containerRef?: React.RefObject<ContainerElement | null>; /** * Ref object for the element that should receive focus when the focus trap is first enabled. * If not provided, one will be created by this hook and returned. Its use is optional. */ initialFocusRef?: React.RefObject<InitialFocusElement | null>; /** * Set to true to disable the focus trap and clean up listeners. Can be re-enabled at any time. */ disabled?: boolean; /** * If true, when this focus trap is cleaned up, restore focus to the element that had focus immediately before the focus trap was enabled. (Default: false) */ restoreFocusOnCleanUp?: boolean; } /** * Hook used to trap focus inside a container. Returns a ref that can be added to the container * that should trap focus. * @param settings {FocusTrapHookSettings} */ export declare function useFocusTrap<ContainerElement extends HTMLElement = HTMLElement, InitialFocusElement extends HTMLElement = HTMLElement>(settings?: FocusTrapHookSettings<ContainerElement, InitialFocusElement>, dependencies?: React.DependencyList): { containerRef: React.RefObject<ContainerElement | null>; initialFocusRef: React.RefObject<InitialFocusElement | null>; }; //# sourceMappingURL=useFocusTrap.d.ts.map