Skip to content

Instantly share code, notes, and snippets.

@denis-ismailaj
Last active November 13, 2024 19:38
Show Gist options
  • Save denis-ismailaj/5a1b7de5c58100680126311275ebab6f to your computer and use it in GitHub Desktop.
Save denis-ismailaj/5a1b7de5c58100680126311275ebab6f to your computer and use it in GitHub Desktop.
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