Clickable

Listen for click events on composables

View in Playground

Constructors

The clickable modifier can be used to listen for a variety of click evens on a composable.

@Composable
fun Modifier.clickable(
    enabled: Boolean = true,
    onClickLabel: String? = null,
    interactionState: InteractionState = remember { InteractionState() },
    indication: Indication? = IndicationAmbient.current(),
    onLongClick: (() -> Unit)? = null,
    onDoubleClick: (() -> Unit)? = null,
    onClick: () -> Unit
)
  • enabled – whether or not the click functionality is enabled

  • onClickLabel – accessibility label for the click action

  • interactionState – the interaction state of the composable, updated when pressed

  • indication – state to be displayed when the composable is pressed

  • onLongClick – a callback for when the composable is long clicked

  • onDoubleClick – a callback for when the composable is double clicked

  • onClick – a callback for when the composable is clicked

    • required

Examples

Using the Clickable modifier

Text(
    text = "Clickable",
    modifier = Modifier.padding(16.dp).clickable(onClick = {

    }, onClickLabel = "Click to open document")
)

Clickable listeners

Text(
    text = "Clickable",
    modifier = Modifier.padding(16.dp).clickable(onClick = {

    }, onLongClick = {

    }, onDoubleClick = {

    })
)