RemoteTextButton

Functions summary

Unit
@Composable
@RemoteComposable
RemoteTextButton(
    onClick: RemoteAction,
    modifier: RemoteModifier,
    enabled: RemoteBoolean,
    shapes: RemoteTextButtonShapes,
    colors: RemoteTextButtonColors,
    border: RemoteBorderStroke?,
    content: @Composable @RemoteComposable () -> Unit
)

Wear Material RemoteTextButton is a circular, text-only button with transparent background and no border.

Functions

@Composable
@RemoteComposable
fun RemoteTextButton(
    onClick: RemoteAction,
    modifier: RemoteModifier = RemoteModifier,
    enabled: RemoteBoolean = true.rb,
    shapes: RemoteTextButtonShapes = RemoteTextButtonDefaults.shapes(),
    colors: RemoteTextButtonColors = RemoteTextButtonDefaults.textButtonColors(),
    border: RemoteBorderStroke? = null,
    content: @Composable @RemoteComposable () -> Unit
): Unit

Wear Material RemoteTextButton is a circular, text-only button with transparent background and no border. It offers a single slot for text.

The default RemoteTextButton has no border and a transparent background for low emphasis actions. For actions that require higher emphasis, consider RemoteTextButtonDefaults.filledTonalTextButtonColors or overriding the colors via RemoteTextButtonColors.copy.

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

Example of a RemoteTextButton with customized colors:

import androidx.compose.remote.creation.compose.action.valueChangeAction
import androidx.compose.remote.creation.compose.state.MutableRemoteInt
import androidx.compose.remote.creation.compose.state.rf
import androidx.compose.remote.creation.compose.state.rs
import androidx.compose.runtime.remember
import androidx.wear.compose.remote.material3.RemoteMaterialTheme
import androidx.wear.compose.remote.material3.RemoteText
import androidx.wear.compose.remote.material3.RemoteTextButton
import androidx.wear.compose.remote.material3.RemoteTextButtonDefaults

val tapCount = remember { MutableRemoteInt(0) }
val text = "+".rs + tapCount.toRemoteString()

RemoteTextButton(
    onClick = valueChangeAction(tapCount, tapCount + 1),
    modifier = modifier,
    colors =
        RemoteTextButtonDefaults.textButtonColors(
            containerColor = RemoteMaterialTheme.colorScheme.primary,
            contentColor = RemoteMaterialTheme.colorScheme.onPrimary,
            disabledContainerColor =
                RemoteMaterialTheme.colorScheme.primary.copy(alpha = 0.12f.rf),
            disabledContentColor = RemoteMaterialTheme.colorScheme.primary.copy(0.38f.rf),
        ),
) {
    RemoteText(text = text)
}

Example of a filled tonal RemoteTextButton:

import androidx.compose.remote.creation.compose.action.valueChangeAction
import androidx.compose.remote.creation.compose.state.MutableRemoteInt
import androidx.compose.remote.creation.compose.state.rs
import androidx.compose.runtime.remember
import androidx.wear.compose.remote.material3.RemoteText
import androidx.wear.compose.remote.material3.RemoteTextButton
import androidx.wear.compose.remote.material3.RemoteTextButtonDefaults

val tapCount = remember { MutableRemoteInt(0) }
val text = "+".rs + tapCount.toRemoteString()

RemoteTextButton(
    onClick = valueChangeAction(tapCount, tapCount + 1),
    modifier = modifier,
    colors = RemoteTextButtonDefaults.filledTonalTextButtonColors(),
) {
    RemoteText(text = text)
}

Example of a RemoteTextButton with corner animation on press:

import androidx.compose.remote.creation.compose.action.hostAction
import androidx.compose.remote.creation.compose.state.rf
import androidx.compose.remote.creation.compose.state.rs
import androidx.wear.compose.remote.material3.RemoteMaterialTheme
import androidx.wear.compose.remote.material3.RemoteText
import androidx.wear.compose.remote.material3.RemoteTextButton
import androidx.wear.compose.remote.material3.RemoteTextButtonDefaults

RemoteTextButton(
    onClick = hostAction("button_click".rs),
    modifier = modifier,
    shapes = RemoteTextButtonDefaults.animatedShapes(),
    colors =
        RemoteTextButtonDefaults.textButtonColors(
            containerColor = RemoteMaterialTheme.colorScheme.primary,
            contentColor = RemoteMaterialTheme.colorScheme.onPrimary,
            disabledContainerColor =
                RemoteMaterialTheme.colorScheme.primary.copy(alpha = 0.12f.rf),
            disabledContentColor = RemoteMaterialTheme.colorScheme.primary.copy(0.38f.rf),
        ),
) {
    RemoteText(text = "ABC".rs)
}
Parameters
onClick: RemoteAction

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.

shapes: RemoteTextButtonShapes = RemoteTextButtonDefaults.shapes()

Defines the shape for this text button, including a pressed shape when animated. Defaults to a static shape based on RemoteTextButtonDefaults.shape, or use RemoteTextButtonDefaults.animatedShapes to animate the corners on press. The press animation is driven by touch events on the player, and is not shown by players that don't dispatch them.

colors: RemoteTextButtonColors = RemoteTextButtonDefaults.textButtonColors()

RemoteTextButtonColors that will be used to resolve the background and content color for this button in different states.

border: RemoteBorderStroke? = null

Optional RemoteBorderStroke that will be used to resolve the border for this button in different states, or null for no border.

content: @Composable @RemoteComposable () -> Unit

The content displayed on the text button, expected to be text or image.