Skip to Content
⭐️ Leave a star →
HooksuseLongPress

useLongPress

Detects a long-press gesture via pointer events. Returns a bundle of handlers you spread onto the target element. The press is cancelled if the pointer moves more than moveThreshold pixels — so scrolling won’t accidentally trigger it.

import { useLongPress } from '@wire-ui/react' function PressableItem() { const handlers = useLongPress( (e) => console.log('long pressed at', e.clientX, e.clientY), { threshold: 500 }, ) return <div {...handlers}>Press and hold</div> }

Parameters

ParamTypeDescription
callback(event: PointerEvent) => voidFires once the press has been held for threshold ms.
optionsUseLongPressOptionsSee below.

Options

OptionTypeDefaultDescription
thresholdnumber400Milliseconds the pointer must stay down before the callback fires.
moveThresholdnumber10Pixels of movement that cancel the press.
onStart(event: PointerEvent) => voidCalled on pointer down.
onFinish(event: PointerEvent) => voidCalled when the threshold is reached and callback fires.
onCancel(event: PointerEvent) => voidCalled when the press is cancelled by movement, release, or pointer leave.
disabledbooleanfalseDisable the gesture entirely.

Returns

A handler bundle to spread onto the target element.

{ onPointerDown, onPointerUp, onPointerLeave, onPointerMove, onPointerCancel }
Last updated on

MIT License © 2026 wire-ui

useLongPress – Wire UI