Skip to content
Selection & Inputs

Checkbox

Single, grouped, and tri-state parent checkboxes

Checkboxes let people select one or more items from a set, or turn a single option on or off. A TriStateCheckbox can act as a parent that reflects and toggles a group of child checkboxes.

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

Examples

01

Parent / child group

A TriStateCheckbox shows On, Off, or Indeterminate for its children.

Kotlin
val children = remember { mutableStateListOf(true, false, false) }
val parentState = when {
    children.all { it } -> ToggleableState.On
    children.none { it } -> ToggleableState.Off
    else -> ToggleableState.Indeterminate
}
TriStateCheckbox(
    state = parentState,
    onClick = {
        val target = parentState != ToggleableState.On
        for (i in children.indices) children[i] = target
    }
)
children.forEachIndexed { index, checked ->
    Checkbox(checked = checked, onCheckedChange = { children[index] = it })
}