Skip to content
On this page

usePageLeave

Category
Export Size
1.11 kB
Last Changed
last year

Reactive state to show whether the mouse leaves the page.

Demo

{
  "isLeft": false
}

Usage

js
import { usePageLeave } from '@vueuse/core'

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

const isLeft = usePageLeave()

Component Usage

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

html
<UsePageLeave v-slot="{ isLeft }">
  Has Left Page: {{ isLeft }}
</UsePageLeave>
<UsePageLeave v-slot="{ isLeft }">
  Has Left Page: {{ isLeft }}
</UsePageLeave>

Type Declarations

typescript
/**
 * 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
vaakian X
lxhyl
wheat
Alex Kozack
Antério Vieira

Changelog

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

Released under the MIT License.