Composables UI is out: our new component library for Compose Multiplatform ->
Compose Component

CompactButtonContent

Lays out the content of a CompactButton with support for an icon and a label.

CompactButtonContentWithOneHandedGestureSample

@Composable
fun CompactButtonContentWithOneHandedGestureSample() {
    var label by remember { mutableStateOf("Compact Button") }
    val onClick = remember { { label = "Gestured" } }
    val interactionSource = remember { MutableInteractionSource() }
    Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
        CompactButton(
            onClick = onClick,
            interactionSource = interactionSource,
            modifier =
                Modifier.oneHandedGesture(
                    action = GestureAction.Primary,
                    interactionSource = interactionSource,
                    onGesture = onClick,
                ),
        ) {
            OneHandedGestureIndicator(
                interactionSource = interactionSource,
                gestureIndicatorTint = MaterialTheme.colorScheme.onPrimary,
            ) {
                CompactButtonContent(
                    icon = {
                        Icon(
                            painter = painterResource(R.drawable.ic_favorite_rounded),
                            contentDescription = "Favorite icon",
                            modifier = Modifier.size(CompactButtonDefaults.ExtraSmallIconSize),
                        )
                    },
                    colors = ButtonDefaults.buttonColors(),
                    label = { Text(label) },
                )
            }
        }
    }
}

Last updated: