Checkbox

Functions summary

Unit
@Composable
Checkbox(
    checked: Boolean,
    onCheckedChange: ((Boolean) -> Unit)?,
    modifier: Modifier,
    enabled: Boolean,
    interactionSource: MutableInteractionSource?,
    colors: CheckboxColors
)

Material Design checkbox

Cmn

Functions

Checkbox

@Composable
fun Checkbox(
    checked: Boolean,
    onCheckedChange: ((Boolean) -> Unit)?,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    interactionSource: MutableInteractionSource? = null,
    colors: CheckboxColors = CheckboxDefaults.colors()
): Unit

Material Design checkbox

Checkboxes allow users to select one or more items from a set. Checkboxes can turn an option on or off.

Checkboxes
image

import androidx.compose.material.Checkbox
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember

val checkedState = remember { mutableStateOf(true) }
Checkbox(checked = checkedState.value, onCheckedChange = { checkedState.value = it })
Parameters
checked: Boolean

whether Checkbox is checked or unchecked

onCheckedChange: ((Boolean) -> Unit)?

callback to be invoked when checkbox is being clicked, therefore the change of checked state in requested. If null, then this is passive and relies entirely on a higher-level component to control the "checked" state.

modifier: Modifier = Modifier

Modifier to be applied to the layout of the checkbox

enabled: Boolean = true

whether the component is enabled or grayed out

interactionSource: MutableInteractionSource? = null

an optional hoisted MutableInteractionSource for observing and emitting Interactions for this checkbox. You can use this to change the checkbox's appearance or preview the checkbox in different states. Note that if null is provided, interactions will still happen internally.

colors: CheckboxColors = CheckboxDefaults.colors()

CheckboxColors that will be used to determine the color of the checkmark / box / border in different states. See CheckboxDefaults.colors.

See also
TriStateCheckbox

if you require support for an indeterminate state, or more advanced color customization between states.