fn
useActiveElement
v0.0.15testeddemoReactive `document.activeElement`, traversing open shadow roots.
Examples
ts
const active = useActiveElement();ts
// keep tracking even if the focused node is detached from the DOM
const active = useActiveElement({ triggerOnRemoval: true });Demo
Loading demo…
Signature
ts
export function useActiveElement<T extends HTMLElement>(
options: UseActiveElementOptions ={ ... }Type Parameters
Textends HTMLElementParameters
| Parameter | Type | Description |
|---|---|---|
options? | UseActiveElementOptions | Options |
Returns
UseActiveElementReturn<T>The currently focused element