💡 Minimize the page or switch tab then return

useDocumentVisibility

Reactively track document.visibilityState

Usage

import { useDocumentVisibility } from '@vueuse/core'

const visibility = useDocumentVisibility()

Component

<UseDocumentVisibility v-slot="{ visibility }">
  Document Visibility: {{ visibility }}
</UseDocumentVisibility>

Type Declarations

/**
 * Reactively track `document.visibilityState`.
 *
 * @see https://vueuse.org/useDocumentVisibility
 * @param options
 */
export declare function useDocumentVisibility({
  document,
}?: ConfigurableDocument): Ref<VisibilityState>

Source

Source • Demo • Docs