Compose Modifier

toggleable

Configure component to make it toggleable via input and accessibility events This version has no MutableInteractionSource or Indication parameters, the default indication from LocalIndication will be used.

ToggleableSample

@Sampled
@Composable
fun ToggleableSample() {
    var checked by remember { mutableStateOf(false) }
    // content that you want to make toggleable
    Text(
        modifier = Modifier.toggleable(value = checked, onValueChange = { checked = it }),
        text = checked.toString(),
    )
}
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: