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

Sean Proctor

03/01/2024, 8:44 PM
I had naively assumed that
Button
would do some magic to make icons look appropriate. It doesn't. You need to set the size and padding appropriately. I don't think it's been mentioned here before.
Sample from the docs:
Copy code
Button(
    onClick = { /* Do something! */ },
    contentPadding = ButtonDefaults.ButtonWithIconContentPadding
) {
    Icon(
        Icons.Filled.Favorite,
        contentDescription = "Localized description",
        modifier = Modifier.size(ButtonDefaults.IconSize)
    )
    Spacer(Modifier.size(ButtonDefaults.IconSpacing))
    Text("Like")
}