---
category: Elements
---
# useMouseInElement
Reactive mouse position related to an element
## Usage
```vue
Hello world
```
## Component Usage
```vue
x: {{ elementX }} y: {{ elementY }} Is Outside: {{ isOutside }}
```
## Directive Usage
```vue
```
## Type Declarations
```ts
export interface MouseInElementOptions extends UseMouseOptions {
/**
* Whether to handle mouse events when the cursor is outside the target element.
* When enabled, mouse position will continue to be tracked even when outside the element bounds.
*
* @default true
*/
handleOutside?: boolean;
/**
* Listen to window resize event
*
* @default true
*/
windowScroll?: boolean;
/**
* Listen to window scroll event
*
* @default true
*/
windowResize?: boolean;
}
/**
* Reactive mouse position related to an element.
*
* @see https://vueuse.org/useMouseInElement
* @param target
* @param options
*/
export declare function useMouseInElement(
target?: MaybeElementRef,
options?: MouseInElementOptions,
): {
x: ShallowRef;
y: ShallowRef;
sourceType: ShallowRef;
elementX: ShallowRef;
elementY: ShallowRef;
elementPositionX: ShallowRef;
elementPositionY: ShallowRef;
elementHeight: ShallowRef;
elementWidth: ShallowRef;
isOutside: ShallowRef;
stop: () => void;
};
export type UseMouseInElementReturn = ReturnType;
```