Build apps faster with our new App builder! Check it out →

OutlinedButton

Android

Component in Wear Material Compose

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

The recommended [Button] sizes can be obtained from [ButtonDefaults] - see [ButtonDefaults.DefaultButtonSize], [ButtonDefaults.LargeButtonSize], [ButtonDefaults.SmallButtonSize]. Icon content should be of size [ButtonDefaults.DefaultIconSize], [ButtonDefaults.LargeIconSize] or [ButtonDefaults.SmallIconSize] respectively.

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

An [OutlinedButton] has a transparent background and a thin border by default with content taking the theme primary color.

Last updated:

Installation

dependencies {
   implementation("androidx.wear.compose:compose-material:1.5.0-alpha04")
}

Overloads

@Composable
fun OutlinedButton(
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    colors: ButtonColors = ButtonDefaults.outlinedButtonColors(),
    interactionSource: MutableInteractionSource? = null,
    shape: Shape = CircleShape,
    border: ButtonBorder = ButtonDefaults.outlinedButtonBorder(),
    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.
colors[ButtonColors] that will be used to resolve the background and content color for this button in different states. See [ButtonDefaults.outlinedButtonColors].
interactionSourcean optional hoisted [MutableInteractionSource] for observing and emitting [Interaction]s 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.
shapeDefines the button's shape. It is strongly recommended to use the default as this shape is a key characteristic of the Wear Material Theme.
border[ButtonBorder] that will be used to resolve the button border in different states. See [ButtonDefaults.outlinedButtonBorder].
contentThe content displayed on the [OutlinedButton] such as text, icon or image.

Code Example

OutlinedButtonWithIcon

@Composable
fun OutlinedButtonWithIcon() {
    OutlinedButton(
        onClick = { /* Do something */ },
        enabled = true,
    ) {
        Icon(
            painter = painterResource(id = R.drawable.ic_airplanemode_active_24px),
            contentDescription = "airplane",
            modifier =
                Modifier.size(ButtonDefaults.DefaultIconSize)
                    .wrapContentSize(align = Alignment.Center),
        )
    }
}
by @alexstyl