Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
LabelledCheckBox in Jetpack Compose
@Composable
fun LabelledCheckBox(
checked: Boolean,
onCheckedChange: ((Boolean) -> Unit),
label: String,
modifier: Modifier = Modifier
) {
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = modifier
.clip(MaterialTheme.shapes.small)
.clickable(
indication = rememberRipple(color = MaterialTheme.colors.primary),
interactionSource = remember { MutableInteractionSource() },
onClick = { onCheckedChange(!checked) }
)
.requiredHeight(ButtonDefaults.MinHeight)
.padding(4.dp)
) {
Checkbox(
checked = checked,
onCheckedChange = null
)
Spacer(Modifier.size(6.dp))
Text(
text = label,
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment