State of Compose 2023 results are in! Click here to learn more

← Back to Wear Material Core

Button

Component
in
Wear Material Core
. Since 1.2.0-rc01

Overview

Code Examples

Video

Wear Material Button that offers a single slot to take any content (text, icon or image).

Button can be enabled or disabled. A disabled button will not respond to click events.

For more information, see the Buttons(https://developer.android.com/training/wearables/components/buttons) guide.

@param onClick Will be called when the user clicks the button. @param modifier Modifier to be applied to the button. @param enabled Controls the enabled state of the button. When false, this button will not be clickable. @param backgroundColor Resolves the background for this button in different states. @param interactionSource The MutableInteractionSource representing the stream of Interactions for this Button. You can create and pass in your own remembered MutableInteractionSource if you want to observe Interactions and customize the appearance / behavior of this Button in different Interactions. @param shape Defines the button's shape. @param border Resolves the border for this button in different states. @param buttonSize The default size of the button unless overridden by Modifier.size. @param content The content displayed on the Button such as text, icon or image.

Overloads

Button

@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@Composable
fun Button(
    onClick: () -> Unit,
    modifier: Modifier,
    enabled: Boolean,
    backgroundColor: @Composable (enabled: Boolean) -> State<Color>,
    interactionSource: MutableInteractionSource,
    shape: Shape,
    border: @Composable (enabled: Boolean) -> State<BorderStroke?>?,
    buttonSize: Dp,
    content: @Composable BoxScope.() -> Unit,
)

Parameters

NameDescription
onClickWill be called when the user clicks the button.
modifierModifier to be applied to the button.
enabledControls the enabled state of the button. When false, this button will not be clickable.
backgroundColorResolves the background for this button in different states.
interactionSourceThe MutableInteractionSource representing the stream of Interactions for this Button. You can create and pass in your own remembered MutableInteractionSource if you want to observe Interactions and customize the appearance / behavior of this Button in different Interactions.
shapeDefines the button's shape.
borderResolves the border for this button in different states.
buttonSizeThe default size of the button unless overridden by Modifier.size.
contentThe content displayed on the Button such as text, icon or image