Skip to content

Instantly share code, notes, and snippets.

@denis-ismailaj
Last active March 21, 2023 18:28
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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