RemoteButton

Functions summary

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

Base level Wear Material3 RemoteButton that offers a single slot to take any content.

Unit
@Composable
@RemoteComposable
RemoteButton(
    onClick: Action,
    containerPainter: RemotePainter,
    modifier: RemoteModifier,
    enabled: RemoteBoolean,
    disabledContainerPainter: RemotePainter,
    colors: RemoteButtonColors,
    border: RemoteDp?,
    borderColor: RemoteColor?,
    shape: RemoteShape,
    contentPadding: RemotePaddingValues,
    content: @Composable @RemoteComposable RemoteRowScope.() -> Unit
)

Base level Wear Material3 RemoteButton that offers parameters for container image backgrounds, with a single slot to take any content.

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

Wear Material3 RemoteButton that offers parameters for optional container image backgrounds, with three slots and a specific layout for an icon, label and secondaryLabel.

Functions

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

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

RemoteButton 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.

Button 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.RemoteButton
import androidx.wear.compose.remote.material3.RemoteText

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

RemoteButton(ValueChange(tapCount, tapCount + 1), modifier = modifier) {
    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

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.

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.

shape: RemoteShape = RemoteButtonDefaults.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

contentPadding: RemotePaddingValues = RemoteButtonDefaults.ContentPadding

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

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.

content: @Composable @RemoteComposable RemoteRowScope.() -> Unit

Slot for composable body content displayed on the Button

@Composable
@RemoteComposable
fun RemoteButton(
    onClick: Action,
    containerPainter: RemotePainter,
    modifier: RemoteModifier = RemoteModifier,
    enabled: RemoteBoolean = true.rb,
    disabledContainerPainter: RemotePainter = RemoteButtonDefaults.disabledContainerPainter(containerPainter),
    colors: RemoteButtonColors = RemoteButtonDefaults.buttonWithNullableContainerPainterColors(containerPainter),
    border: RemoteDp? = null,
    borderColor: RemoteColor? = null,
    shape: RemoteShape = RemoteButtonDefaults.shape,
    contentPadding: RemotePaddingValues = RemoteButtonDefaults.ContentPadding,
    content: @Composable @RemoteComposable RemoteRowScope.() -> Unit
): Unit

Base level Wear Material3 RemoteButton that offers parameters for container image backgrounds, with a single slot to take any content.

An Image background is a means to reinforce the meaning of information in a Button. Buttons should have a content color that contrasts with the background image and scrim.

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

Parameters
onClick: Action

Will be called when the user clicks the button

containerPainter: RemotePainter

The background image of this RemoteButton when enabled

modifier: RemoteModifier = RemoteModifier

Modifier to be applied to 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.

disabledContainerPainter: RemotePainter = RemoteButtonDefaults.disabledContainerPainter(containerPainter)

The background image of this RemoteButton when disabled

colors: RemoteButtonColors = RemoteButtonDefaults.buttonWithNullableContainerPainterColors(containerPainter)

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.

shape: RemoteShape = RemoteButtonDefaults.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

contentPadding: RemotePaddingValues = RemoteButtonDefaults.ContentPadding

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

content: @Composable @RemoteComposable RemoteRowScope.() -> Unit

Slot for composable body content displayed on the Button

@Composable
@RemoteComposable
fun RemoteButton(
    onClick: Action,
    modifier: RemoteModifier = RemoteModifier,
    secondaryLabel: (@Composable @RemoteComposable RemoteRowScope.() -> Unit)? = null,
    icon: (@Composable () -> Unit)? = null,
    enabled: RemoteBoolean = true.rb,
    containerPainter: RemotePainter? = null,
    disabledContainerPainter: RemotePainter? = null,
    colors: RemoteButtonColors = RemoteButtonDefaults.buttonWithNullableContainerPainterColors(containerPainter),
    border: RemoteDp? = null,
    borderColor: RemoteColor? = null,
    shape: RemoteShape = RemoteButtonDefaults.shape,
    contentPadding: RemotePaddingValues = RemoteButtonDefaults.ContentPadding,
    label: @Composable @RemoteComposable RemoteRowScope.() -> Unit
): Unit

Wear Material3 RemoteButton that offers parameters for optional container image backgrounds, with three slots and a specific layout for an icon, label and secondaryLabel. The icon and secondaryLabel are optional. The items are laid out with the icon, if provided, at the start of a row, with a column next containing the two label slots.

An image background is a means to reinforce the meaning of information in a Button. Buttons should have a content color that contrasts with the background image and scrim.

This RemoteButton takes containerPainter for the container image background to be drawn when the button is enabled and disabledContainerPainter for the image background when the button is disabled (the RemoteButtonColors containerColor and disabledContainerColor properties are ignored). It is recommended to use RemoteButtonDefaults.containerPainter to create the painters so that a scrim is drawn on top of the container image, ensuring that any content above the background is legible. If painters are not provided, a tonal color shape would be used as the button background.

The RemoteButton is stadium-shaped by default and its standard height is designed to take 2 lines of text - either a two-line label or both a single line label and a secondary label. With localisation and/or large font sizes, the RemoteButton height adjusts to accommodate the contents. The label and secondary label should be consistently aligned.

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

Example of a RemoteButton with an image background, an icon and a secondary label:

Parameters
onClick: Action

Will be called when the user clicks the button

modifier: RemoteModifier = RemoteModifier

Modifier to be applied to the button

secondaryLabel: (@Composable @RemoteComposable RemoteRowScope.() -> Unit)? = null

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: (@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.IconSize or RemoteButtonDefaults.LargeIconSize.

enabled: RemoteBoolean = true.rb

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

containerPainter: RemotePainter? = null

The RemotePainter to use to draw the container image of the RemoteButton, such as returned by RemoteButtonDefaults.containerPainter.

disabledContainerPainter: RemotePainter? = null

RemotePainter to use to draw the container of the RemoteButton when not enabled, such as returned by RemoteButtonDefaults.disabledContainerPainter.

colors: RemoteButtonColors = RemoteButtonDefaults.buttonWithNullableContainerPainterColors(containerPainter)

RemoteButtonColors 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 RemoteButtonDefaults.buttonWithContainerPainterColors.

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.

shape: RemoteShape = RemoteButtonDefaults.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

contentPadding: RemotePaddingValues = RemoteButtonDefaults.ContentPadding

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

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

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.