OutlinedCompactButton

Functions summary

Unit
@Composable
OutlinedCompactButton(
    onClick: () -> Unit,
    modifier: Modifier,
    enabled: Boolean,
    colors: ButtonColors,
    backgroundPadding: Dp,
    interactionSource: MutableInteractionSource?,
    shape: Shape,
    border: ButtonBorder,
    content: @Composable BoxScope.() -> Unit
)

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

Functions

OutlinedCompactButton

@Composable
fun OutlinedCompactButton(
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    colors: ButtonColors = ButtonDefaults.outlinedButtonColors(),
    backgroundPadding: Dp = ButtonDefaults.CompactButtonBackgroundPadding,
    interactionSource: MutableInteractionSource? = null,
    shape: Shape = CircleShape,
    border: ButtonBorder = ButtonDefaults.outlinedButtonBorder(),
    content: @Composable BoxScope.() -> Unit
): Unit

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

The OutlinedCompactButton has background size ButtonDefaults.ExtraSmallButtonSize. There is an transparent padding around the background, defaulted to ButtonDefaults.CompactButtonBackgroundPadding, which increases the clickable area. Icon content should have size ButtonDefaults.SmallIconSize.

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

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

Example usage:

import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.wear.compose.material.Button
import androidx.wear.compose.material.ButtonDefaults
import androidx.wear.compose.material.CompactButton
import androidx.wear.compose.material.Icon
import androidx.wear.compose.material.OutlinedCompactButton

OutlinedCompactButton(onClick = { /* Do something */ }, enabled = true) {
    Icon(
        painter = painterResource(id = R.drawable.ic_airplanemode_active_24px),
        contentDescription = "airplane",
        modifier =
            Modifier.size(ButtonDefaults.SmallIconSize)
                .wrapContentSize(align = Alignment.Center),
    )
}

For more information, see the Buttons guide.

Parameters
onClick: () -> Unit

Will be called when the user clicks the button.

modifier: Modifier = Modifier

Modifier to be applied to the button.

enabled: Boolean = true

Controls the enabled state of the button. When false, this button will not be clickable.

colors: ButtonColors = ButtonDefaults.outlinedButtonColors()

ButtonColors that will be used to resolve the background and content color for this button in different states. See ButtonDefaults.outlinedButtonColors.

backgroundPadding: Dp = ButtonDefaults.CompactButtonBackgroundPadding

Increases the transparent clickable area around the background, defaults to ButtonDefaults.CompactButtonBackgroundPadding

interactionSource: MutableInteractionSource? = null

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.

shape: Shape = CircleShape

Defines 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 = ButtonDefaults.outlinedButtonBorder()

ButtonBorder that will be used to resolve the button border in different states. See ButtonDefaults.outlinedButtonBorder.

content: @Composable BoxScope.() -> Unit

The content displayed on the OutlinedCompactButton such as text, icon or image.