RemoteCompactButton

Functions summary

Unit
@Composable
@RemoteComposable
RemoteCompactButton(
    onClick: Action,
    modifier: RemoteModifier,
    icon: (@Composable () -> Unit)?,
    enabled: RemoteBoolean,
    shape: RemoteShape,
    colors: RemoteButtonColors,
    border: RemoteDp?,
    borderColor: RemoteColor?,
    contentPadding: RemotePaddingValues,
    label: (@Composable @RemoteComposable RemoteRowScope.() -> Unit)?
)

A Wear Material3 RemoteCompactButton that offers two slots and a specific layout for an icon and label.

Functions

@Composable
@RemoteComposable
fun RemoteCompactButton(
    onClick: Action,
    modifier: RemoteModifier = RemoteModifier,
    icon: (@Composable () -> Unit)? = null,
    enabled: RemoteBoolean = true.rb,
    shape: RemoteShape = RemoteButtonDefaults.compactButtonShape,
    colors: RemoteButtonColors = RemoteButtonDefaults.buttonColors(),
    border: RemoteDp? = null,
    borderColor: RemoteColor? = null,
    contentPadding: RemotePaddingValues = RemoteButtonDefaults.CompactButtonContentPadding,
    label: (@Composable @RemoteComposable RemoteRowScope.() -> Unit)?
): Unit

A Wear Material3 RemoteCompactButton 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.

The RemoteCompactButton is Stadium shaped and has a max height designed to take no more than one line of text and/or one icon. The default max height is ButtonDefaults.CompactButtonHeight. This includes a visible button height of 32.dp and 8.dp of padding above and below the button in order to meet accessibility guidelines that request a minimum of 48.dp height and width of tappable area.

If an icon is provided then the labels should be "start" aligned, e.g. left aligned in left-to-right mode so that the text starts next to the icon.

The items are laid out as follows.

  1. If a label is provided then the button will be laid out with the optional icon at the start of a row followed by the label with a default max height of RemoteButtonDefaults.CompactButtonHeight.

  2. If only an icon is provided it will be laid out vertically and horizontally centered with a default height of RemoteButtonDefaults.CompactButtonHeight and the default width of RemoteButtonDefaults.IconOnlyCompactButtonWidth

If neither icon nor label is provided then the button will displayed like an icon only button but with no contents or background color.

RemoteCompactButton takes the RemoteButtonDefaults.buttonColors color scheme by default, with colored background, contrasting content color and no border. This is a high-emphasis button for the primary, most important or most common action on a screen.

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

import androidx.compose.remote.core.operations.TextFromFloat
import androidx.compose.remote.creation.compose.action.ValueChange
import androidx.compose.remote.creation.compose.state.rememberMutableRemoteInt
import androidx.compose.remote.creation.compose.state.rs
import androidx.wear.compose.remote.material3.RemoteCompactButton
import androidx.wear.compose.remote.material3.RemoteText

val tapCount = rememberMutableRemoteInt(0)
val countSuffix = " (".rs + tapCount.toRemoteString(10, TextFromFloat.PAD_PRE_NONE) + " taps)"

RemoteCompactButton(
    ValueChange(tapCount, tapCount + 1),
    modifier = modifier,
    label = { RemoteText("Tap me!".rs + countSuffix) },
)
Parameters
onClick: Action

Will be called when the user clicks the button

modifier: RemoteModifier = RemoteModifier

Modifier to be applied to the button

icon: (@Composable () -> Unit)? = null

A slot for providing the button's icon. The contents are expected to be a horizontally and vertically aligned icon of size RemoteButtonDefaults.ExtraSmallIconSize when used with a label or RemoteButtonDefaults.SmallIconSize when used as the only content in the button.

enabled: RemoteBoolean = true.rb

Controls the enabled state of the button. When false, this button will not be clickable. It must be a constant value.

shape: RemoteShape = RemoteButtonDefaults.compactButtonShape

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: RemoteButtonColors = RemoteButtonDefaults.buttonColors()

RemoteButtonColors that will be used to resolve the background and content color for this button in different states. See RemoteButtonDefaults.buttonColors.

border: RemoteDp? = null

Optional RemoteDp that will be used to resolve the border for this button in different states.

borderColor: RemoteColor? = null

Optional RemoteColor that will be used to resolve the border color for this button in different states.

contentPadding: RemotePaddingValues = RemoteButtonDefaults.CompactButtonContentPadding

The spacing values to apply internally between the container and the content

label: (@Composable @RemoteComposable RemoteRowScope.() -> Unit)?

Slot for composable body content displayed on the Button