TextButtonDefaults

object TextButtonDefaults


Contains the default values used by TextButton.

Summary

Public functions

Shape
@Composable
animatedShape(
    interactionSource: InteractionSource,
    shape: CornerBasedShape,
    pressedShape: CornerBasedShape
)

Creates a Shape with a animation between two CornerBasedShapes.

TextButtonColors

Creates a TextButtonColors with the colors for a filled TextButton- by default, a colored background with a contrasting content color.

TextButtonColors
@Composable
filledTextButtonColors(
    containerColor: Color,
    contentColor: Color,
    disabledContainerColor: Color,
    disabledContentColor: Color
)

Creates a TextButtonColors with the colors for a filled TextButton- by default, a colored background with a contrasting content color.

TextButtonColors

Creates a TextButtonColors with the colors for a filled, tonal TextButton- by default, a muted colored background with a contrasting content color.

TextButtonColors
@Composable
filledTonalTextButtonColors(
    containerColor: Color,
    contentColor: Color,
    disabledContainerColor: Color,
    disabledContentColor: Color
)

Creates a TextButtonColors with the colors for a filled, tonal TextButton- by default, a muted colored background with a contrasting content color.

TextButtonColors

Creates a TextButtonColors as an alternative to the filledTonal TextButtonColors, giving a surface with more chroma to indicate selected or highlighted states that are not primary calls-to-action.

TextButtonColors
@Composable
filledVariantTextButtonColors(
    containerColor: Color,
    contentColor: Color,
    disabledContainerColor: Color,
    disabledContentColor: Color
)

Creates a TextButtonColors as an alternative to the filledTonal TextButtonColors, giving a surface with more chroma to indicate selected or highlighted states that are not primary calls-to-action.

TextButtonColors

Creates a TextButtonColors with the colors for an outlined TextButton- by default, a transparent background with contrasting content color.

TextButtonColors
@Composable
outlinedTextButtonColors(
    contentColor: Color,
    disabledContentColor: Color
)

Creates a TextButtonColors with the colors for an outlined TextButton- by default, a transparent background with contrasting content color.

TextButtonColors

Creates a TextButtonColors for a text button - by default, a transparent background with contrasting content color.

TextButtonColors
@Composable
textButtonColors(
    containerColor: Color,
    contentColor: Color,
    disabledContainerColor: Color,
    disabledContentColor: Color
)

Creates a TextButtonColors for a text button - by default, a transparent background with contrasting content color.

Public properties

Dp

The default size applied for buttons.

Dp

The recommended size for a large button.

Dp

The recommended size for a small button.

TextStyle

The default text style applied for buttons.

TextStyle

The recommended text style for a large button.

CornerBasedShape

Recommended pressed Shape for TextButton.

RoundedCornerShape

Recommended Shape for TextButton.

TextStyle

The recommended text style for a small button.

Public functions

animatedShape

Added in 1.0.0-alpha25
@Composable
fun animatedShape(
    interactionSource: InteractionSource,
    shape: CornerBasedShape = TextButtonDefaults.shape,
    pressedShape: CornerBasedShape = TextButtonDefaults.pressedShape
): Shape

Creates a Shape with a animation between two CornerBasedShapes.

A simple text button using the default colors, animated when pressed.

import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.runtime.remember
import androidx.wear.compose.material3.ButtonDefaults
import androidx.wear.compose.material3.Text
import androidx.wear.compose.material3.TextButton
import androidx.wear.compose.material3.TextButtonDefaults

val interactionSource = remember { MutableInteractionSource() }
TextButton(
    onClick = { /* Do something */ },
    shape = TextButtonDefaults.animatedShape(interactionSource),
    interactionSource = interactionSource
) {
    Text(text = "ABC")
}

A simple text toggle button using the default colors, animated when pressed.

import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.wear.compose.material3.Text
import androidx.wear.compose.material3.TextButtonDefaults
import androidx.wear.compose.material3.TextToggleButton

val interactionSource = remember { MutableInteractionSource() }
var checked by remember { mutableStateOf(true) }
TextToggleButton(
    checked = checked,
    onCheckedChange = { checked = !checked },
    interactionSource = interactionSource,
    shape =
        TextButtonDefaults.animatedShape(
            interactionSource = interactionSource,
        ),
) {
    Text(text = if (checked) "On" else "Off")
}
Parameters
interactionSource: InteractionSource

the interaction source applied to the Button.

shape: CornerBasedShape = TextButtonDefaults.shape

The normal shape of the TextButton.

pressedShape: CornerBasedShape = TextButtonDefaults.pressedShape

The pressed shape of the TextButton.

filledTextButtonColors

Added in 1.0.0-alpha25
@Composable
fun filledTextButtonColors(): TextButtonColors

Creates a TextButtonColors with the colors for a filled TextButton- by default, a colored background with a contrasting content color. If the text button is disabled then the colors will default to ColorScheme.onSurface with suitable alpha values applied.

filledTextButtonColors

@Composable
fun filledTextButtonColors(
    containerColor: Color = Color.Unspecified,
    contentColor: Color = Color.Unspecified,
    disabledContainerColor: Color = Color.Unspecified,
    disabledContentColor: Color = Color.Unspecified
): TextButtonColors

Creates a TextButtonColors with the colors for a filled TextButton- by default, a colored background with a contrasting content color. If the text button is disabled then the colors will default to ColorScheme.onSurface with suitable alpha values applied.

Example of TextButton with filledTextButtonColors:

import androidx.wear.compose.material3.ButtonDefaults
import androidx.wear.compose.material3.Text
import androidx.wear.compose.material3.TextButton
import androidx.wear.compose.material3.TextButtonDefaults

TextButton(
    onClick = { /* Do something */ },
    colors = TextButtonDefaults.filledTextButtonColors()
) {
    Text(text = "ABC")
}
Parameters
containerColor: Color = Color.Unspecified

The background color of this text button when enabled

contentColor: Color = Color.Unspecified

The content color of this text button when enabled

disabledContainerColor: Color = Color.Unspecified

the background color of this text button when not enabled

disabledContentColor: Color = Color.Unspecified

the content color of this text button when not enabled

filledTonalTextButtonColors

Added in 1.0.0-alpha25
@Composable
fun filledTonalTextButtonColors(): TextButtonColors

Creates a TextButtonColors with the colors for a filled, tonal TextButton- by default, a muted colored background with a contrasting content color. If the text button is disabled then the colors will default to ColorScheme.onSurface with suitable alpha values applied.

filledTonalTextButtonColors

@Composable
fun filledTonalTextButtonColors(
    containerColor: Color = Color.Unspecified,
    contentColor: Color = Color.Unspecified,
    disabledContainerColor: Color = Color.Unspecified,
    disabledContentColor: Color = Color.Unspecified
): TextButtonColors

Creates a TextButtonColors with the colors for a filled, tonal TextButton- by default, a muted colored background with a contrasting content color. If the text button is disabled then the colors will default to ColorScheme.onSurface with suitable alpha values applied.

Example of TextButton with filledTonalTextButtonColors:

import androidx.wear.compose.material3.ButtonDefaults
import androidx.wear.compose.material3.Text
import androidx.wear.compose.material3.TextButton
import androidx.wear.compose.material3.TextButtonDefaults

TextButton(
    onClick = { /* Do something */ },
    colors = TextButtonDefaults.filledTonalTextButtonColors()
) {
    Text(text = "ABC")
}
Parameters
containerColor: Color = Color.Unspecified

The background color of this text button when enabled

contentColor: Color = Color.Unspecified

The content color of this text button when enabled

disabledContainerColor: Color = Color.Unspecified

the background color of this text button when not enabled

disabledContentColor: Color = Color.Unspecified

the content color of this text button when not enabled

filledVariantTextButtonColors

Added in 1.0.0-alpha25
@Composable
fun filledVariantTextButtonColors(): TextButtonColors

Creates a TextButtonColors as an alternative to the filledTonal TextButtonColors, giving a surface with more chroma to indicate selected or highlighted states that are not primary calls-to-action. If the text button is disabled then the colors will default to the MaterialTheme onSurface color with suitable alpha values applied.

Example of creating a TextButton with filledVariantTextButtonColors:

import androidx.wear.compose.material3.ButtonDefaults
import androidx.wear.compose.material3.Text
import androidx.wear.compose.material3.TextButton
import androidx.wear.compose.material3.TextButtonDefaults

TextButton(
    onClick = { /* Do something */ },
    colors = TextButtonDefaults.filledVariantTextButtonColors()
) {
    Text(text = "ABC")
}

filledVariantTextButtonColors

@Composable
fun filledVariantTextButtonColors(
    containerColor: Color = Color.Unspecified,
    contentColor: Color = Color.Unspecified,
    disabledContainerColor: Color = Color.Unspecified,
    disabledContentColor: Color = Color.Unspecified
): TextButtonColors

Creates a TextButtonColors as an alternative to the filledTonal TextButtonColors, giving a surface with more chroma to indicate selected or highlighted states that are not primary calls-to-action. If the text button is disabled then the colors will default to the MaterialTheme onSurface color with suitable alpha values applied.

Example of creating a TextButton with filledVariantTextButtonColors:

import androidx.wear.compose.material3.ButtonDefaults
import androidx.wear.compose.material3.Text
import androidx.wear.compose.material3.TextButton
import androidx.wear.compose.material3.TextButtonDefaults

TextButton(
    onClick = { /* Do something */ },
    colors = TextButtonDefaults.filledVariantTextButtonColors()
) {
    Text(text = "ABC")
}
Parameters
containerColor: Color = Color.Unspecified

The background color of this text button when enabled

contentColor: Color = Color.Unspecified

The content color of this text button when enabled

disabledContainerColor: Color = Color.Unspecified

the background color of this text button when not enabled

disabledContentColor: Color = Color.Unspecified

the content color of this text button when not enabled

outlinedTextButtonColors

Added in 1.0.0-alpha25
@Composable
fun outlinedTextButtonColors(): TextButtonColors

Creates a TextButtonColors with the colors for an outlined TextButton- by default, a transparent background with contrasting content color. If the button is disabled, then the colors will default to ColorScheme.onSurface with suitable alpha values applied.

outlinedTextButtonColors

@Composable
fun outlinedTextButtonColors(
    contentColor: Color = Color.Unspecified,
    disabledContentColor: Color = Color.Unspecified
): TextButtonColors

Creates a TextButtonColors with the colors for an outlined TextButton- by default, a transparent background with contrasting content color. If the button is disabled, then the colors will default to ColorScheme.onSurface with suitable alpha values applied.

Example of TextButton with outlinedTextButtonColors and ButtonDefaults.outlinedButtonBorder:

import androidx.wear.compose.material3.ButtonDefaults
import androidx.wear.compose.material3.Text
import androidx.wear.compose.material3.TextButton
import androidx.wear.compose.material3.TextButtonDefaults

TextButton(
    onClick = { /* Do something */ },
    colors = TextButtonDefaults.outlinedTextButtonColors(),
    border = ButtonDefaults.outlinedButtonBorder(enabled = true)
) {
    Text(text = "ABC")
}
Parameters
contentColor: Color = Color.Unspecified

The content color of this text button when enabled

disabledContentColor: Color = Color.Unspecified

The content color of this text button when not enabled

textButtonColors

Added in 1.0.0-alpha25
@Composable
fun textButtonColors(): TextButtonColors

Creates a TextButtonColors for a text button - by default, a transparent background with contrasting content color. If the button is disabled then the colors default to ColorScheme.onSurface with suitable alpha values applied.

textButtonColors

@Composable
fun textButtonColors(
    containerColor: Color = Color.Transparent,
    contentColor: Color = Color.Unspecified,
    disabledContainerColor: Color = Color.Transparent,
    disabledContentColor: Color = Color.Unspecified
): TextButtonColors

Creates a TextButtonColors for a text button - by default, a transparent background with contrasting content color. If the button is disabled then the colors default to ColorScheme.onSurface with suitable alpha values applied.

Parameters
containerColor: Color = Color.Transparent

the background color of this text button when enabled

contentColor: Color = Color.Unspecified

the content color of this text button when enabled

disabledContainerColor: Color = Color.Transparent

the background color of this text button when not enabled

disabledContentColor: Color = Color.Unspecified

the content color of this text button when not enabled

Public properties

DefaultButtonSize

Added in 1.0.0-alpha25
val DefaultButtonSizeDp

The default size applied for buttons. It is recommended to apply this size using Modifier.touchTargetAwareSize.

LargeButtonSize

Added in 1.0.0-alpha25
val LargeButtonSizeDp

The recommended size for a large button. It is recommended to apply this size using Modifier.touchTargetAwareSize.

SmallButtonSize

Added in 1.0.0-alpha25
val SmallButtonSizeDp

The recommended size for a small button. It is recommended to apply this size using Modifier.touchTargetAwareSize.

defaultButtonTextStyle

Added in 1.0.0-alpha25
val defaultButtonTextStyleTextStyle

The default text style applied for buttons.

largeButtonTextStyle

Added in 1.0.0-alpha25
val largeButtonTextStyleTextStyle

The recommended text style for a large button.

pressedShape

Added in 1.0.0-alpha25
val pressedShapeCornerBasedShape

Recommended pressed Shape for TextButton.

shape

Added in 1.0.0-alpha25
val shapeRoundedCornerShape

Recommended Shape for TextButton.

smallButtonTextStyle

Added in 1.0.0-alpha25
val smallButtonTextStyleTextStyle

The recommended text style for a small button.