useDocumentVisibility
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 Usage
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
Contributors
Anthony Fu
Antério Vieira
Shinigami
wheat
Alex Kozack
Scott Bedard