Base level Wear Material3 Button that offers a single slot to take any content. Used as the container for more opinionated Button components that take specific content such as icons and labels.

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

Parameters

onClick Will be called when the user clicks the button
modifier Modifier to be applied to the button
onLongClick Called when this button is long clicked (long-pressed). When this callback is set, onLongClickLabel should be set as well.
onLongClickLabel Semantic / accessibility label for the onLongClick action.
enabled Controls the enabled state of the button. When false, this button will not be clickable
shape Defines the button's shape. It is strongly recommended to use the default as this shape is a key characteristic of the Wear Material3 Theme
colors ButtonColors that will be used to resolve the background and content color for this button in different states. See ButtonDefaults.buttonColors.
border Optional BorderStroke that will be used to resolve the border for this button in different states.
contentPadding The spacing values to apply internally between the container and the content
interactionSource an 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.
transformation Transformation to be used when button appears inside a container that needs to dynamically change its content separately from the background.
content Slot for composable body content displayed on the Button
Android
@Composable
public fun Button(
    onClick: () -> Unit,
    containerPainter: Painter,
    modifier: Modifier = Modifier,
    onLongClick: (() -> Unit)? = null,
    onLongClickLabel: String? = null,
    enabled: Boolean = true,
    disabledContainerPainter: Painter = ButtonDefaults.disabledContainerPainter(containerPainter),
    shape: Shape = ButtonDefaults.shape,
    colors: ButtonColors = ButtonDefaults.buttonWithContainerPainterColors(),
    border: BorderStroke? = null,
    contentPadding: PaddingValues = ButtonDefaults.ContentPadding,
    interactionSource: MutableInteractionSource? = null,
    transformation: SurfaceTransformation? = null,
    content: @Composable RowScope.() -> Unit,
): Unit

Parameters

onClick Will be called when the user clicks the button
containerPainter The Painter to use to draw the container image of the Button, such as returned by ButtonDefaults.containerPainter.
modifier Modifier to be applied to the button
onLongClick Called when this button is long clicked (long-pressed). When this callback is set, onLongClickLabel should be set as well.
onLongClickLabel Semantic / accessibility label for the onLongClick action.
enabled Controls the enabled state of the button. When false, this button will not be clickable
disabledContainerPainter Painter to use to draw the container of the Button when not enabled, such as returned by ButtonDefaults.containerPainter with alpha = ButtonDefaults.DisabledContainerAlpha.
shape Defines the button's shape. It is strongly recommended to use the default as this shape is a key characteristic of the Wear Material3 Theme
colors ButtonColors that will be used to resolve the background and content color for this button in different states (the containerColor and disabledContainerColor are overridden by containerPainter and disabledContainerPainter respectively). See ButtonDefaults.buttonWithContainerPainterColors.
border Optional BorderStroke that will be used to resolve the border for this button in different states.
contentPadding The spacing values to apply internally between the container and the content
interactionSource an 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.
transformation Transformation to be used when button appears inside a container that needs to dynamically change its content separately from the background.
content Slot for composable body content displayed on the Button
Android
@Composable
public fun Button(
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
    onLongClick: (() -> Unit)? = null,
    onLongClickLabel: String? = null,
    secondaryLabel: (@Composable RowScope.() -> Unit)? = null,
    icon: (@Composable BoxScope.() -> Unit)? = null,
    enabled: Boolean = true,
    shape: Shape = ButtonDefaults.shape,
    colors: ButtonColors = ButtonDefaults.buttonColors(),
    border: BorderStroke? = null,
    contentPadding: PaddingValues = ButtonDefaults.ContentPadding,
    interactionSource: MutableInteractionSource? = null,
    transformation: SurfaceTransformation? = null,
    label: @Composable RowScope.() -> Unit,
): Unit

Parameters

onClick Will be called when the user clicks the button
modifier Modifier to be applied to the button
onLongClick Called when this button is long clicked (long-pressed). When this callback is set, onLongClickLabel should be set as well.
onLongClickLabel Semantic / accessibility label for the onLongClick action.
secondaryLabel A slot for providing the button's secondary label. The contents are expected to be text which is "start" aligned if there is an icon preset and "start" or "center" aligned if not. label and secondaryLabel contents should be consistently aligned.
icon A slot for providing the button's icon. The contents are expected to be a horizontally and vertically aligned icon of size ButtonDefaults.IconSize or ButtonDefaults.LargeIconSize.
enabled Controls the enabled state of the button. When false, this button will not be clickable
shape Defines the button's shape. It is strongly recommended to use the default as this shape is a key characteristic of the Wear Material3 Theme
colors ButtonColors that will be used to resolve the background and content color for this button in different states. See ButtonDefaults.buttonColors. Defaults to ButtonDefaults.buttonColors
border Optional BorderStroke that will be used to resolve the button border in different states.
contentPadding The spacing values to apply internally between the container and the content
interactionSource an 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.
transformation Transformation to be used when button appears inside a container that needs to dynamically change its content separately from the background.
label A slot for providing the button's main label. The contents are expected to be text which is "start" aligned if there is an icon preset and "start" or "center" aligned if not.
Android
@Composable
public fun Button(
    onClick: () -> Unit,
    containerPainter: Painter,
    modifier: Modifier = Modifier,
    onLongClick: (() -> Unit)? = null,
    onLongClickLabel: String? = null,
    secondaryLabel: (@Composable RowScope.() -> Unit)? = null,
    icon: (@Composable BoxScope.() -> Unit)? = null,
    enabled: Boolean = true,
    disabledContainerPainter: Painter = ButtonDefaults.disabledContainerPainter(containerPainter),
    shape: Shape = ButtonDefaults.shape,
    colors: ButtonColors = ButtonDefaults.buttonWithContainerPainterColors(),
    border: BorderStroke? = null,
    contentPadding: PaddingValues = ButtonDefaults.ContentPadding,
    interactionSource: MutableInteractionSource? = null,
    transformation: SurfaceTransformation? = null,
    label: @Composable RowScope.() -> Unit,
): Unit

Parameters

onClick Will be called when the user clicks the button
containerPainter The Painter to use to draw the container image of the Button, such as returned by ButtonDefaults.containerPainter.
modifier Modifier to be applied to the button
onLongClick Called when this button is long clicked (long-pressed). When this callback is set, onLongClickLabel should be set as well.
onLongClickLabel Semantic / accessibility label for the onLongClick action.
secondaryLabel A slot for providing the button's secondary label. The contents are expected to be text which is "start" aligned if there is an icon preset and "start" or "center" aligned if not. label and secondaryLabel contents should be consistently aligned.
icon A slot for providing the button's icon. The contents are expected to be a horizontally and vertically aligned icon of size ButtonDefaults.IconSize or ButtonDefaults.LargeIconSize.
enabled Controls the enabled state of the button. When false, this button will not be clickable
disabledContainerPainter Painter to use to draw the container of the Button when not enabled, such as returned by ButtonDefaults.disabledContainerPainter.
shape Defines the button's shape. It is strongly recommended to use the default as this shape is a key characteristic of the Wear Material3 Theme
colors ButtonColors that will be used to resolve the background and content color for this button in different states (the containerColor and disabledContainerColor are overridden by containerPainter and disabledContainerPainter respectively). See ButtonDefaults.buttonWithContainerPainterColors.
border Optional BorderStroke that will be used to resolve the button border in different states.
contentPadding The spacing values to apply internally between the container and the content
interactionSource an 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.
transformation Transformation to be used when button appears inside a container that needs to dynamically change its content separately from the background.
label A slot for providing the button's main label. The contents are expected to be text which is "start" aligned if there is an icon preset and "start" or "center" aligned if not.

Code Examples

ButtonExtraLargeIconSample

@Composable
fun ButtonExtraLargeIconSample(
    modifier: Modifier = Modifier.fillMaxWidth(),
    enabled: Boolean = true,
) {
    // When customising the icon size, it is recommended to also specify
    // the associated content padding
    Button(
        onClick = { /* Do something */ },
        enabled = enabled,
        label = { Text("Button") },
        secondaryLabel = { Text("Secondary label") },
        icon = {
            Icon(
                painter = painterResource(R.drawable.ic_favorite_rounded),
                contentDescription = "Favorite icon",
                modifier = Modifier.size(ButtonDefaults.ExtraLargeIconSize),
            )
        },
        contentPadding = ButtonDefaults.ButtonWithExtraLargeIconContentPadding,
        modifier = modifier,
    )
}

ButtonLargeIconSample

@Composable
fun ButtonLargeIconSample(modifier: Modifier = Modifier.fillMaxWidth(), enabled: Boolean = true) {
    // When customising the icon size, it is recommended to also specify
    // the associated content padding
    Button(
        onClick = { /* Do something */ },
        enabled = enabled,
        label = { Text("Button") },
        secondaryLabel = { Text("Secondary label") },
        icon = {
            Icon(
                painter = painterResource(R.drawable.ic_favorite_rounded),
                contentDescription = "Favorite icon",
                modifier = Modifier.size(ButtonDefaults.LargeIconSize),
            )
        },
        contentPadding = ButtonDefaults.ButtonWithLargeIconContentPadding,
        modifier = modifier,
    )
}

ButtonSample

@Composable
fun ButtonSample(modifier: Modifier = Modifier.fillMaxWidth()) {
    Button(
        onClick = { /* Do something */ },
        label = { Text("Button") },
        secondaryLabel = { Text("Secondary label") },
        icon = {
            Icon(
                painter = painterResource(R.drawable.ic_favorite_rounded),
                contentDescription = "Favorite icon",
                modifier = Modifier.size(ButtonDefaults.IconSize),
            )
        },
        modifier = modifier,
    )
}

ButtonWithImageSample

@Composable
fun ButtonWithImageSample(modifier: Modifier = Modifier.fillMaxWidth(), enabled: Boolean = true) {
    Button(
        onClick = { /* Do something */ },
        containerPainter =
            ButtonDefaults.containerPainter(
                image = painterResource(id = R.drawable.backgroundimage)
            ),
        enabled = enabled,
        label = { Text("Button") },
        secondaryLabel = { Text("Secondary label") },
        icon = {
            Icon(
                painter = painterResource(R.drawable.ic_favorite_rounded),
                contentDescription = "Favorite icon",
            )
        },
        modifier = modifier,
    )
}

SimpleButtonSample

@Composable
fun SimpleButtonSample(modifier: Modifier = Modifier) {
    Button(onClick = { /* Do something */ }, label = { Text("Simple Button") }, modifier = modifier)
}