Skip to content
On this page

useDocumentVisibility

Category
Export Size
1.07 kB
Last Changed
5 months ago

Reactively track document.visibilityState

Demo

💡 Minimize the page or switch tab then return

Usage

js
import { useDocumentVisibility } from '@vueuse/core'

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

const visibility = useDocumentVisibility()

Component Usage

This function also provides a renderless component version via the @vueuse/components package. Learn more about the usage.

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

Type Declarations

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

Source

Source • Demo • Docs

Contributors

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

Changelog

v7.7.1 on 3/5/2022
54a9a - fix: use indirect type (#1337)

Released under the MIT License.