Select the inputs below to see the changes
Current Active Element: null

useActiveElement

Reactive document.activeElement

Usage

import { useActiveElement } from '@vueuse/core'

const activeElement = useActiveElement()

watch(activeElement, (el) => {
  console.log('focus changed to', el)
})

Type Declarations

/**
 * Reactive `document.activeElement`
 *
 * @see /useActiveElement
 * @param options
 */
export declare function useActiveElement<T extends HTMLElement>(
  options?: ConfigurableWindow
): ComputedRef<T | null | undefined>

Source

SourceDemoDocs