Device-agnostic interaction
Support mouse, touch, and stylus input through one event model.
React 19+ · Type Alias
PointerEvent is React’s handler type for pointer interactions on DOM components. Its event object combines pointer-specific information with inherited mouse-event properties.
PointerEvent is the React event-handler type for pointer interactions. Its event object includes pointer-specific data such as coordinates, device type, pressure, identity, and tilt, together with inherited mouse-event properties.
(event: React.PointerEvent) => void| Name | Type | Description |
|---|---|---|
e | React.PointerEvent | The React event object passed to the pointer handler; it includes pointer-specific properties and inherited MouseEvent properties. |
A pointer-event handler returns nothing required by React; its purpose is to respond to the event.
function PointerTracker() {
return (
<div
onPointerEnter={e => console.log('enter', e.pointerType)}
onPointerMove={e => console.log('move', e.clientX, e.clientY)}
onPointerDown={e => console.log('down', e.isPrimary)}
onPointerUp={e => console.log('up', e.pressure)}
onPointerLeave={e => console.log('leave')}
/>
);
}A component can attach pointer handlers directly to a DOM element and read pointer-specific fields from the React event.
Support mouse, touch, and stylus input through one event model.
Read coordinates while an input device moves over an element.
Use pressure, tilt, or pointer identity for drawing and rich input.
PointerEvent is the handler type used for pointer events in React. The event object exposes fields such as pointerId, pointerType, pressure, width, height, tiltX, tiltY, and twist, plus inherited mouse-event properties.
Follow-up: How would you distinguish input devices? Read pointerType, which identifies the kind of pointer involved, and use pointer-specific fields such as pressure when relevant.
Use pointer props such as onPointerEnter, onPointerMove, onPointerDown, onPointerUp, and onPointerLeave on a DOM element. Each receives a React event object that can be inspected in the handler.
Follow-up: Which event should represent an interrupted interaction? Include onPointerCancel because the browser can cancel a pointer interaction.
Pointer handlers also provide mouse-style information, including clientX, clientY, button, buttons, movementX, movementY, pageX, pageY, screenX, screenY, and modifier-key state. This lets one handler work with common coordinate and button data while retaining pointer-specific information.
Follow-up: How can a handler account for multitouch or multiple simultaneous pointers? Use pointerId to distinguish individual pointers and isPrimary to identify the primary pointer.
onPointerCancelonPointerDownonPointerEnteronPointerLeaveonPointerMoveonPointerUponGotPointerCaptureonLostPointerCapture