Skip to content
On this page

usePageLeave

Category
Last Changed
a month ago

Reactive state to show whether the mouse leaves the page.

Demo

{
  "isLeft": false
}

Usage

import { usePageLeave } from '@vueuse/core'

const isLeft = usePageLeave()
import { usePageLeave } from '@vueuse/core'

const isLeft = usePageLeave()

Component

This function also provides a renderless component version via the @vueuse/components package. Learn more about the usage.
<UsePageLeave v-slot="{ isLeft }">
  Has Left Page: {{ isLeft }}
</UsePageLeave>
<UsePageLeave v-slot="{ isLeft }">
  Has Left Page: {{ isLeft }}
</UsePageLeave>

Type Declarations

/**
 * Reactive state to show whether mouse leaves the page.
 *
 * @see https://vueuse.org/usePageLeave
 * @param options
 */
export declare function usePageLeave(options?: ConfigurableWindow): Ref<boolean>
/**
 * Reactive state to show whether mouse leaves the page.
 *
 * @see https://vueuse.org/usePageLeave
 * @param options
 */
export declare function usePageLeave(options?: ConfigurableWindow): Ref<boolean>

Source

SourceDemoDocs

Contributors

Anthony Fu
lxhyl
wheat
Alex Kozack
Antério Vieira

Changelog

v5.0.0-beta.2 on 5/25/2021
5bede - feat: introduce components & directives (#486)
usePageLeave has loaded