androidx.compose.material3
Checkbox
Composable function
A checkbox turns an item on or off. Use checkboxes when the user can pick several items from a list.
For a single setting that takes effect right away, use a Switch.
The checkbox does not remember its state. You keep it in a variable and update it in onCheckedChange.

var checked by remember { mutableStateOf(true) }
Checkbox(checked = checked, onCheckedChange = { checked = it })

Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
Checkbox(checked = true, onCheckedChange = {})
Checkbox(checked = false, onCheckedChange = {})
Checkbox(checked = true, onCheckedChange = {}, enabled = false)
Checkbox(checked = false, onCheckedChange = {}, enabled = false)
}
Basic
Uses the default line widths.
@Composable
fun Checkbox(
checked: Boolean,
onCheckedChange: ((Boolean) -> Unit)?,
modifier: Modifier = Modifier,
enabled: Boolean = true,
colors: CheckboxColors = CheckboxDefaults.colors(),
interactionSource: MutableInteractionSource? = null,
)
checked: BooleanRequired
checked: BooleanRequiredWhether the box is checked. Pass your state here.
onCheckedChange: ((Boolean) -> Unit)?Required
onCheckedChange: ((Boolean) -> Unit)?RequiredCalled with the new value when the user clicks. Update your state here.
Pass null if a whole row handles the click. This makes the label clickable too.

var agree by remember { mutableStateOf(false) }
Row(
modifier = Modifier.toggleable(value = agree, onValueChange = { agree = it }, role = Role.Checkbox),
verticalAlignment = Alignment.CenterVertically,
) {
// The Row handles clicks, so the checkbox itself does not.
Checkbox(checked = agree, onCheckedChange = null)
Text("I agree to the terms", Modifier.padding(start = 8.dp))
}
modifier: ModifierOptional
modifier: ModifierOptionalDefault: Modifier
Changes size, padding, or position of the checkbox. See the Modifier guide.
enabled: BooleanOptional
enabled: BooleanOptionalDefault: true
Set to false to make the checkbox gray and not clickable.
colors: CheckboxColorsOptional
colors: CheckboxColorsOptionalDefault: CheckboxDefaults.colors()
Sets the box, checkmark and border colors for every state.
Make one with CheckboxDefaults.colors. Pass only the colors you want to change.

Checkbox(
checked = true,
onCheckedChange = {},
colors = CheckboxDefaults.colors(checkedColor = MaterialTheme.colorScheme.tertiary),
)
interactionSource: MutableInteractionSource?Optional
interactionSource: MutableInteractionSource?OptionalDefault: null
Lets you observe or control press, hover and focus states. Leave it null unless your code must react to them. See InteractionSource.
Custom strokesSince 1.9
Takes checkmarkStroke and outlineStroke to change line widths.
@Composable
fun Checkbox(
checked: Boolean,
onCheckedChange: ((Boolean) -> Unit)?,
checkmarkStroke: Stroke,
outlineStroke: Stroke,
modifier: Modifier = Modifier,
enabled: Boolean = true,
colors: CheckboxColors = CheckboxDefaults.colors(),
interactionSource: MutableInteractionSource? = null,
)
checkmarkStroke: StrokeRequired
checkmarkStroke: StrokeRequiredThe line style of the checkmark, for example Stroke(width = 3f).
outlineStroke: StrokeRequired
outlineStroke: StrokeRequiredThe line style of the box outline.
Same as above: checked, onCheckedChange, modifier, enabled, colors, interactionSource.
Checkbox types
CheckboxTriStateCheckbox
See also
CheckboxDefaults: default values and helper functions forCheckbox.