Skip to content

useDocumentVisibility

Category
Export Size
542 B
Last Changed
3 minutes 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>

Source

SourceDemoDocs

Contributors

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

Changelog

v9.11.0 on 1/17/2023
d5321 - fix(components): mark defineComponent as pure (#2623)

Released under the MIT License.