Skip to content

CheckboxCore

@Composable



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



 (isHovered: Boolean) -> Unit
)

A stateless, unstyled toggle composable.

CheckboxCore manages hover state internally and exposes it to content. 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 }) { isHovered ->
    Box(modifier = Modifier.size(16, 16).background(if (checked) KColor.GREEN else KColor.GRAY))
}

Parameters

  • checked: The current checked state.

  • modifier: Additional modifiers applied to the outer Box.

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

  • content: The visual content; receives isHovered for styling.