Compose SwiftUIv0.4.0
esc
GuideAPIGitHub
View modifier

onTapGesture(_:)

Runs an action when the view is tapped.

iOS 17.0+macOS 14.0+tvOS 17.0+watchOS 10.0+
fun Modifier.onTapGesture(count: Int = 1, perform: () -> Unit): Modifier

Overview

For the location of the tap, use Modifier.onTapGesture { x, y -> }.

Modifier.onTapGesture(perform = { })

This is the Kotlin form of SwiftUI View.onTapGesture(count:perform:): SwiftUI documentation. In Swift it reads:

nonisolated func onTapGesture(count: Int = 1, perform action: @escaping () -> Void) -> some View

Topics

Overloads

fun Modifier.onTapGesture(count: Int = 1, perform: () -> Unit): Modifier
SwiftUI View.onTapGesture(count:perform:)