Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply VueUse composables in Vue 3/Nuxt projects to replace custom implementations with battle-tested utilities.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/useWindowFocus.md
1---2category: Elements3---45# useWindowFocus67Reactively track window focus with `window.onfocus` and `window.onblur` events.89## Usage1011```vue12<script setup lang="ts">13import { useWindowFocus } from '@vueuse/core'1415const focused = useWindowFocus()16</script>1718<template>19<div>{{ focused }}</div>20</template>21```2223## Component Usage2425```vue26<template>27<UseWindowFocus v-slot="{ focused }">28Document Focus: {{ focused }}29</UseWindowFocus>30</template>31```3233## Type Declarations3435```ts36/**37* Reactively track window focus with `window.onfocus` and `window.onblur`.38*39* @see https://vueuse.org/useWindowFocus40*41* @__NO_SIDE_EFFECTS__42*/43export declare function useWindowFocus(44options?: ConfigurableWindow,45): ShallowRef<boolean>46```47