The
clickable
modifier allows apps to detect clicks on the element it's applied to.
@Composable private fun ClickableSample() { val count = remember { mutableStateOf(0) } // content that you want to make clickable Text( text = count.value.toString(), modifier = Modifier.clickable { count.value += 1 } ) }
When more flexibility is needed, you can provide a tap gesture detector via the
pointerInput
modifier:
Modifier.pointerInput(Unit) { detectTapGestures( onPress = { /* Called when the gesture starts */ }, onDoubleTap = { /* Called on Double Tap */ }, onLongPress = { /* Called on Long Press */ }, onTap = { /* Called on Tap */ } ) }