Composable Function

RemoteButton

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

RemoteButtonSimpleSample

@Sampled
@Composable
@WearPreviewDevices
@PreviewWrapper(RemoteComponentPreviewWrapper::class)
fun RemoteButtonSimpleSample(modifier: RemoteModifier = RemoteModifier) {
    val tapCount = remember { MutableRemoteInt(0) }
    val countSuffix = " (".rs + tapCount.toRemoteString() + " taps)".rs

    RemoteButton(valueChangeAction(tapCount, tapCount + 1), modifier = modifier) {
        RemoteText("Tap me!".rs + countSuffix)
    }
}

RemoteButtonWithContainerPainterSample

@Sampled
@Composable
@WearPreviewDevices
@PreviewWrapper(RemoteComponentPreviewWrapper::class)
fun RemoteButtonWithContainerPainterSample(modifier: RemoteModifier = RemoteModifier) {
    val backgroundImage = remember {
        createNamedRemoteImageBitmap(name = "buttonBackground") {
            ImageBitmap(200, 100).also { bitmap ->
                val canvas = Canvas(bitmap)
                canvas.drawRect(
                    Rect(0f, 0f, 200f, 100f),
                    Paint().apply { color = Color(0xFF1A5276) },
                )
            }
        }
    }
    RemoteButton(
        onClick = hostAction("open_image".rs),
        containerPainter = RemoteButtonDefaults.containerPainter(backgroundImage),
        modifier = modifier,
    ) {
        RemoteText("Image background".rs)
    }
}

RemoteButtonWithIconAndSecondaryLabelSample

@Sampled
@Composable
@WearPreviewDevices
@PreviewWrapper(RemoteComponentPreviewWrapper::class)
fun RemoteButtonWithIconAndSecondaryLabelSample(modifier: RemoteModifier = RemoteModifier) {
    RemoteButton(
        onClick = hostAction("favorite_click".rs),
        modifier = modifier,
        icon = {
            RemoteIcon(
                imageVector = Icons.Filled.Favorite.toRemoteImageVector(),
                contentDescription = "Favorite".rs,
                modifier = RemoteModifier.size(RemoteButtonDefaults.IconSize),
            )
        },
        secondaryLabel = { RemoteText("Secondary label".rs) },
        label = { RemoteText("Primary label".rs) },
    )
}
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: