Skip to content

useDocumentVisibility

Category
Export Size
626 B
Last Changed
last month

Reactively track document.visibilityState

Demo

💡 Minimize the page or switch tab then return

Usage

vue
<script setup lang="ts">
import { 
useDocumentVisibility
} from '@vueuse/core'
const
visibility
=
useDocumentVisibility
()
</script>

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

ts
export interface UseDocumentVisibilityOptions extends ConfigurableDocument {}
export type 
UseDocumentVisibilityReturn
=
ShallowRef
<
DocumentVisibilityState
>
/** * Reactively track `document.visibilityState`. * * @see https://vueuse.org/useDocumentVisibility * * @__NO_SIDE_EFFECTS__ */ export declare function
useDocumentVisibility
(
options
?: UseDocumentVisibilityOptions,
):
UseDocumentVisibilityReturn

Source

SourceDemoDocs

Contributors

Anthony Fu
Anthony Fu
Antério Vieira
Vida Xie
webfanzc
IlyaL
SerKo
青椒肉丝
Robin
IlyaL
James Garbutt
Fernando Fernández
vaakian X
Jelf
Shinigami
wheat
Alex Kozack
Scott Bedard

Changelog

v14.2.0 on
e8be8 - fix: fix type inference from string to Documen… (#5248)
v14.0.0-alpha.0 on
8c521 - feat(components)!: refactor components and make them consistent (#4912)
v13.6.0 on
d32f8 - refactor: add @__NO_SIDE_EFFECTS__ annotations to all pure functions (#4907)
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.

The new era of AI engineering.
Workflows, artifacts, and judgment that scale.
Request Early Access