https://kotlinlang.org logo
#compose
Title
# compose
z

Zach Klippenstein (he/him) [MOD]

08/11/2020, 6:57 PM
There isn’t a Composable yet for a Checkbox that includes a correctly-positioned text label, is there?
Checkbox
requires an
onCheckChanged
function, which is unfortunate if you want to make the label clickable as well, since now you’re passing the same handler twice, and the checkbox itself is still clickable but with its own ripple.
I’m doing this, and it still looks weird (need padding between the label, ripple indication issue):
Copy code
Row(
          modifier = Modifier.clickable(onClick = { isChecked = !isChecked }),
          verticalGravity = Alignment.CenterVertically
      ) {
        Checkbox(checked = isChecked, onCheckedChange = { isChecked = it })
        Text("Check me, or don't.")
      }
c

Colton Idle

08/12/2020, 10:45 PM
Oooh. I definitely have had this issue with the current UI toolkit. Checkboxes end up being a nightmare because my designers sometimes want the checkbox + text to be selectable, but sometimes they want ONLY the checkbox to be selectable. Would be awesome to see if compose could solve that elegantly.