Skip to content
Gestures & Scroll

Clickable

Modifier.clickable and combinedClickable for taps and long presses

Modifier.clickable makes any composable respond to taps. combinedClickable adds long-press and double-tap callbacks, letting a plain Box behave like a button.

Clickable demos rendered in Compose Playground
Pixel-accurate preview · light theme

Examples

01

Tap and long press

combinedClickable distinguishes a tap from a long press.

Kotlin
var label by remember { mutableStateOf("Tap or long-press me") }
var count by remember { mutableIntStateOf(0) }
Box(
    Modifier
        .clip(RoundedCornerShape(12.dp))
        .background(MaterialTheme.colorScheme.primaryContainer)
        .combinedClickable(
            onClick = { count++; label = "Tapped $count" },
            onLongClick = { label = "Long-pressed!" }
        )
        .padding(24.dp)
) {
    Text(label)
}