💡 Click somewhere outside of the document to unfocus.
useWindowFocus
Reactively track window focus with window.onfocus
and window.onblur
events.
Usage
import { useWindowFocus } from '@vueuse/core'
const focused = useWindowFocus()
Component
<UseWindowFocus v-slot="{ focused }">
Document Focus: {{ focused }}
</UseWindowFocus>
Type Declarations
/**
* Reactively track window focus with `window.onfocus` and `window.onblur`.
*
* @see /useWindowFocus
* @param options
*/
export declare function useWindowFocus({
window,
}?: ConfigurableWindow): Ref<boolean>