Skip to main content
Gesture modifiers attach interaction handlers to any component. onTapGesture runs on a single (or multi-) tap; onDragGesture reports drag translation and velocity through every phase; onLongPressGesture fires after a press-and-hold; onHover tracks pointer enter/leave on web and desktop. For interactive controls, prefer Button directly — gesture modifiers are best for adding handling to otherwise non-interactive components like Text, Image, and shapes.

onTapGesture

Runs an action when the component is tapped.
action
(locationInView: Point) => void
required
A callback that receives the tap location as a Point ({ x, y }) in the component’s coordinate space.
props
object
Configuration options for the tap gesture.
Single tap
Simple tap action (ignoring location)
Double tap
Combining single and double tap
The locationInView is in the tapped component’s local coordinate space, with { x: 0, y: 0 } at the top-leading corner. When combining single and multi-tap gestures, apply the higher count gesture first — the system waits briefly to distinguish between single and multi-tap. For interactive controls like buttons, prefer using Button directly.

onDragGesture

Tracks drag gestures with translation and velocity.
action
(state: DragGestureState) => void
required
A callback that receives the drag gesture state throughout the gesture lifecycle.
props
object
Configuration options for the drag gesture.
Basic drag tracking
With minimum distance Require a longer drag before recognition to avoid interfering with taps.
Swipe detection using velocity
The gesture callback fires for every phase: "possible", "began", "changed", "ended", and "cancelled". translation is cumulative from the initial touch point, not a per-frame delta. velocity is in points per second and is useful for flick/swipe detection.

onLongPressGesture

Tracks long press gestures.
action
(state: GestureState) => void
required
A callback that receives the gesture state throughout the gesture lifecycle.
props
object
Configuration options for the long press gesture.
Basic long press
Custom duration Require a 2-second press.
Visual feedback during press
The gesture callback fires for every phase: "possible", "began", "changed", "ended", and "cancelled". Use "began" and "changed" to show press-in-progress feedback, and "ended" to perform the action. If the finger moves beyond maximumDistance, the gesture is cancelled.

onHover

Fires when the pointer hovers over or leaves the component.
action
(isHovering: boolean) => void
required
A callback that receives true when the pointer enters the component and false when it leaves.
Hover highlight
Changing text on hover
Scale effect on hover
This modifier is primarily useful for web and desktop pointer interactions. On touch-only devices, hover events do not occur. Currently only supported on the web platform.

See also

  • Button — interactive control with built-in tap handling
  • contextMenu — show a menu on long press or right-click
  • allowsHitTesting — control whether a component receives events
  • contentShape — define the hit-testing region