onTapGesture

Adds an action to perform when this view recognizes a tap gesture, and provides the action with the location of the interaction.

View ModifieriOS 27.0+macOS 27.0+tvOS 27.0+watchOS 27.0+visionOS 27.0+

Overloads

3 ways to call compose().onTapGesture(). Each is one SwiftUI overload, picked by the arguments you pass.

React
compose().onTapGesture({
  count?: number,
  coordinateSpace?: SwiftUI.CoordinateSpaceProtocol,
  inputKinds?: SwiftUI.GestureInputKinds,
  perform: (arg0: CGPoint) => void,
})
Swift
nonisolated func onTapGesture(
    count: Int = 1,
    coordinateSpace: some CoordinateSpaceProtocol = .local,
    inputKinds: GestureInputKinds = .all,
    perform action: @escaping (CGPoint) -> Void
) -> some View

Parameters

  • options.countnumber

    The number of taps or clicks required to trigger the action closure provided in action.

  • options.coordinateSpaceSwiftUI.CoordinateSpaceProtocol

    The coordinate space in which to receive location values.

  • options.inputKindsSwiftUI.GestureInputKinds

    A set of input kinds that this gesture recognizes. If not specified, the gesture will recognize all applicable input kinds that a person can use to perform it.

  • options.perform*(arg0: CGPoint) => void

See also

More in Events and lifecycle.