Compose Modifier

triStateToggleable

Configure component to make it toggleable via input and accessibility events with three states: On, Off and Indeterminate.

TriStateToggleableSample

@Sampled
@Composable
fun TriStateToggleableSample() {
    var checked by remember { mutableStateOf(ToggleableState.Indeterminate) }
    // content that you want to make toggleable
    Text(
        modifier =
            Modifier.triStateToggleable(
                state = checked,
                onClick = {
                    checked =
                        if (checked == ToggleableState.On) ToggleableState.Off
                        else ToggleableState.On
                },
            ),
        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: