Skip to content

useDocumentVisibility

Category
Export Size
599 B
Last Changed
2 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()

Component Usage

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

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

Type Declarations

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

Source

SourceDemoDocs

Contributors

Anthony Fu
Anthony Fu
Antério Vieira
IlyaL
James Garbutt
Fernando Fernández
vaakian X
Jelf
Shinigami
wheat
Alex Kozack
Scott Bedard

Changelog

v12.4.0 on
dd316 - feat: use passive event handlers everywhere is possible (#4477)
v12.0.0-beta.1 on
0a9ed - feat!: drop Vue 2 support, optimize bundles and clean up (#4349)

Released under the MIT License.

Save 37% on one year of learning Vue, Includes the Vue.js Master Class.
Get Offer