CompactButton

Composable Component

A Wear Material3 CompactButton that offers two slots and a specific layout for an icon and label. Both the icon and label are optional however it is expected that at least one will be provided.

Android
@Composable
public fun CompactButton(
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
    onLongClick: (() -> Unit)? = null,
    onLongClickLabel: String? = null,
    icon: (@Composable BoxScope.() -> Unit)? = null,
    enabled: Boolean = true,
    shape: Shape = ButtonDefaults.compactButtonShape,
    colors: ButtonColors = ButtonDefaults.buttonColors(),
    border: BorderStroke? = null,
    contentPadding: PaddingValues = ButtonDefaults.CompactButtonContentPadding,
    interactionSource: MutableInteractionSource? = null,
    transformation: SurfaceTransformation? = null,
    label: (@Composable RowScope.() -> Unit)? = null,
)

Parameters

onClickWill be called when the user clicks the button
modifierModifier to be applied to the button
onLongClickCalled when this button is long clicked (long-pressed). When this callback is set, onLongClickLabel should be set as well.
onLongClickLabelSemantic / accessibility label for the onLongClick action.
iconA slot for providing the button's icon. The contents are expected to be a horizontally and vertically aligned icon of size ButtonDefaults.ExtraSmallIconSize when used with a label or ButtonDefaults.SmallIconSize when used as the only content in the button.
enabledControls the enabled state of the button. When false, this button will not be clickable.
shapeDefines the button's shape. It is strongly recommended to use the default as this shape is a key characteristic of the Wear Material3 Theme
colorsButtonColors that will be used to resolve the background and content color for this button in different states. See ButtonDefaults.buttonColors.
borderOptional BorderStroke that will be used to resolve the border for this button in different states.
contentPaddingThe spacing values to apply internally between the container and the content
interactionSourcean optional hoisted MutableInteractionSource for observing and emitting Interactions for this button. You can use this to change the button's appearance or preview the button in different states. Note that if null is provided, interactions will still happen internally.
transformationTransformation to be used when button appears inside a container that needs to dynamically change its content separately from the background.
labelA slot for providing the button's main label. The contents are expected to be a single line of text which is "start" aligned if there is an icon preset and "center" aligned if not.