DEMO
Select inputs below to see the active element -
Current active element is - <unknown>

useActiveElement

Reactive document.activeElement, returns a reference to current active element, the DOM node.

Usage

import { useActiveElement } from '@react-hooks-library/core'

export function Demo() {
  const { activeElement } = useActiveElement()

  return <div>{activeElement?.tagName}</div>
}

Type Declarations

/**
 * Reactive document.activeElement, returns a reference to current active element
 *
 * @returns current active element (DOM node)
 **/
declare function useActiveElement(): {
    activeElement: Element | null;
};

Source

Source | Demo | Docs