Skip to content

CheckboxCore

@Composable



fun CheckboxCore(
    checked: Boolean = false, 
    enabled: Boolean = true, 
    onCheckedChange: (Boolean) -> Unit, 
    content: @Composable



 (modifier: Modifier, isHovered: Boolean, isFocused: Boolean) -> Unit
)

A stateless, unstyled toggle composable, built on Modifier.toggleable.

CheckboxCore manages hover/focus state internally and hands content the Modifier it needs to apply to its own node to participate in pointer/focus input - it's a vanilla keyboard/controller focus-navigation stop that toggles on Enter/Space while focused, the same as a mouse click. All visual styling (textures, colours, checked indicator) is the responsibility of content. Use this as the base for custom or theme-driven checkbox implementations.

Example

var checked by remember { mutableStateOf(false) }
CheckboxCore(checked = checked, onCheckedChange = { checked = it }) { modifier, isHovered, isFocused ->
    Box(modifier = modifier.size(16, 16).background(if (checked) KColor.GREEN else KColor.GRAY))
}

Parameters

  • checked: The current checked state.

  • enabled: When false, pointer and activation-key events are ignored and this drops out of the vanilla focus graph entirely.

  • onCheckedChange: Called with the new checked value when the user clicks.

  • content: The visual content; receives the Modifier to apply to its own node, plus isHovered/isFocused for styling.