@supunlakmal/hooks
Version:
A collection of reusable React hooks
10 lines (9 loc) • 415 B
TypeScript
import { RefObject } from 'react';
/**
* Tracks whether the referenced element or any of its descendants have focus.
* Similar to the :focus-within CSS pseudo-class.
*
* @param elementRef The React ref attached to the container element.
* @returns `true` if the element or a descendant has focus, `false` otherwise.
*/
export declare function useFocusWithinState(elementRef: RefObject<HTMLElement>): boolean;