Skip to content

usePageLeave

Category
Export Size
707 B
Last Changed
last month

Reactive state to show whether the mouse leaves the page.

Demo

{
  "isLeft": false
}

Usage

ts
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.

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

Type Declarations

ts
/**
 * Reactive state to show whether mouse leaves the page.
 *
 * @see https://vueuse.org/usePageLeave
 * @param options
 *
 * @__NO_SIDE_EFFECTS__
 */
export declare function 
usePageLeave
(
options
?:
ConfigurableWindow
,
):
ShallowRef
<boolean, boolean>
export type
UsePageLeaveReturn
=
ReturnType
<typeof
usePageLeave
>

Source

SourceDemoDocs

Contributors

Anthony Fu
SerKo
IlyaL
Fernando Fernández
Anthony Fu
vaakian X
lxhyl
wheat
Alex Kozack
Antério Vieira

Changelog

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.

Turn AI into a coding partner
Claim 40% off for AIDD Masterclass.
Get discount