Skip to content
On this page

useDocumentVisibility

Category
Last Changed
3 days ago

Reactively track document.visibilityState

Demo

💡 Minimize the page or switch tab then return

Usage

import { useDocumentVisibility } from '@vueuse/core'

const visibility = useDocumentVisibility()
import { useDocumentVisibility } from '@vueuse/core'

const visibility = useDocumentVisibility()

Component

This function also provides a renderless component version via the @vueuse/components package. Learn more about the usage.
<UseDocumentVisibility v-slot="{ visibility }">
  Document Visibility: {{ visibility }}
</UseDocumentVisibility>
<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<Document["visibilityState"]>
/**
 * Reactively track `document.visibilityState`.
 *
 * @see https://vueuse.org/useDocumentVisibility
 * @param options
 */
export declare function useDocumentVisibility({
  document,
}?: ConfigurableDocument): Ref<Document["visibilityState"]>

Source

SourceDemoDocs

Contributors

Anthony Fu
Antério Vieira
Shinigami
wheat
Alex Kozack
Scott Bedard

Changelog

v7.7.1 on 3/5/2022
54a9a - fix: use indirect type (#1337)
v5.0.0-beta.2 on 5/25/2021
5bede - feat: introduce components & directives (#486)
useDocumentVisibility has loaded