useMouse

Track the position of the mouse, in the page or relative to an element.

This is custom React hooks, you need to follow the Basic Rules when you use it.

General

The position is relative to the box when the ref is used.

APIs

useMouse

const useMouse = <T extends HTMLElement = HTMLElement>() => {
  ref: RefObject<T | null>
  x: number
  y: number
}
Edit this page on GitHub