TextToggleButtonDefaults

object TextToggleButtonDefaults


Contains the default values used by TextToggleButton.

Summary

Public functions

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

Creates a Shape with a animation between two CornerBasedShapes based on the pressed state.

TextToggleButtonColors

Creates a TextToggleButtonColors for a TextToggleButton

TextToggleButtonColors
@Composable
textToggleButtonColors(
    checkedContainerColor: Color,
    checkedContentColor: Color,
    uncheckedContainerColor: Color,
    uncheckedContentColor: Color,
    disabledCheckedContainerColor: Color,
    disabledCheckedContentColor: Color,
    disabledUncheckedContainerColor: Color,
    disabledUncheckedContentColor: Color
)

Creates a TextToggleButtonColors for a TextToggleButton

Shape
@Composable
variantAnimatedShape(
    interactionSource: InteractionSource,
    checked: Boolean,
    uncheckedCornerSize: CornerSize,
    checkedCornerSize: CornerSize,
    pressedCornerSize: CornerSize,
    onPressAnimationSpec: FiniteAnimationSpec<Float>,
    onReleaseAnimationSpec: FiniteAnimationSpec<Float>
)

Creates a Shape with an animation between three CornerSizes based on the pressed state and checked/unchecked.

Public properties

CornerSize

The recommended size for a Checked button when animated.

Dp

The default size applied for text toggle buttons.

Dp

The recommended size for an extra large text toggle button.

Dp

The recommended size for a large text toggle button.

CornerSize

The recommended size for a Pressed button when animated.

CornerSize

The recommended size for an Unchecked button when animated.

TextStyle

The default text style applied for text toggle buttons.

TextStyle

The recommended text style for an extra large text toggle button.

TextStyle

The recommended text style for a large text toggle button.

CornerBasedShape

Recommended pressed Shape for TextToggleButton.

RoundedCornerShape

Recommended Shape for TextToggleButton.

Public functions

animatedShape

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

Creates a Shape with a animation between two CornerBasedShapes based on the pressed state.

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 = TextToggleButtonDefaults.shape

The normal shape of the TextToggleButton.

pressedShape: CornerBasedShape = TextToggleButtonDefaults.pressedShape

The pressed shape of the TextToggleButton.

textToggleButtonColors

Added in 1.0.0-alpha26
@Composable
fun textToggleButtonColors(): TextToggleButtonColors

Creates a TextToggleButtonColors for a TextToggleButton

textToggleButtonColors

@Composable
fun textToggleButtonColors(
    checkedContainerColor: Color = Color.Unspecified,
    checkedContentColor: Color = Color.Unspecified,
    uncheckedContainerColor: Color = Color.Unspecified,
    uncheckedContentColor: Color = Color.Unspecified,
    disabledCheckedContainerColor: Color = Color.Unspecified,
    disabledCheckedContentColor: Color = Color.Unspecified,
    disabledUncheckedContainerColor: Color = Color.Unspecified,
    disabledUncheckedContentColor: Color = Color.Unspecified
): TextToggleButtonColors

Creates a TextToggleButtonColors for a TextToggleButton

Parameters
checkedContainerColor: Color = Color.Unspecified

the container color of this TextToggleButton when enabled and checked

checkedContentColor: Color = Color.Unspecified

the content color of this TextToggleButton when enabled and checked

uncheckedContainerColor: Color = Color.Unspecified

the container color of this TextToggleButton when enabled and unchecked

uncheckedContentColor: Color = Color.Unspecified

the content color of this TextToggleButton when enabled and unchecked

disabledCheckedContainerColor: Color = Color.Unspecified

the container color of this TextToggleButton when checked and not enabled

disabledCheckedContentColor: Color = Color.Unspecified

the content color of this TextToggleButton when checked and not enabled

disabledUncheckedContainerColor: Color = Color.Unspecified

the container color of this TextToggleButton when unchecked and not enabled

disabledUncheckedContentColor: Color = Color.Unspecified

the content color of this TextToggleButton when unchecked and not enabled

variantAnimatedShape

Added in 1.0.0-alpha26
@Composable
fun variantAnimatedShape(
    interactionSource: InteractionSource,
    checked: Boolean,
    uncheckedCornerSize: CornerSize = UncheckedCornerSize,
    checkedCornerSize: CornerSize = CheckedCornerSize,
    pressedCornerSize: CornerSize = PressedCornerSize,
    onPressAnimationSpec: FiniteAnimationSpec<Float> = MaterialTheme.motionScheme.rememberFastSpatialSpec(),
    onReleaseAnimationSpec: FiniteAnimationSpec<Float> = MaterialTheme.motionScheme.slowSpatialSpec()
): Shape

Creates a Shape with an animation between three CornerSizes based on the pressed state and checked/unchecked.

A simple text toggle button using the default colors, animated on Press and Check/Uncheck:

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.TextToggleButton
import androidx.wear.compose.material3.TextToggleButtonDefaults

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

the interaction source applied to the Button.

checked: Boolean

the current checked/unchecked state.

uncheckedCornerSize: CornerSize = UncheckedCornerSize

the size of the corner when unchecked.

checkedCornerSize: CornerSize = CheckedCornerSize

the size of the corner when checked.

pressedCornerSize: CornerSize = PressedCornerSize

the size of the corner when pressed.

onPressAnimationSpec: FiniteAnimationSpec<Float> = MaterialTheme.motionScheme.rememberFastSpatialSpec()

the spec for press animation.

onReleaseAnimationSpec: FiniteAnimationSpec<Float> = MaterialTheme.motionScheme.slowSpatialSpec()

the spec for release animation.

Public properties

CheckedCornerSize

Added in 1.0.0-alpha26
val CheckedCornerSizeCornerSize

The recommended size for a Checked button when animated.

DefaultButtonSize

Added in 1.0.0-alpha26
val DefaultButtonSizeDp

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

ExtraLargeButtonSize

Added in 1.0.0-alpha26
val ExtraLargeButtonSizeDp

The recommended size for an extra large text toggle button. It is recommended to apply this size using Modifier.touchTargetAwareSize.

LargeButtonSize

Added in 1.0.0-alpha26
val LargeButtonSizeDp

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

PressedCornerSize

Added in 1.0.0-alpha26
val PressedCornerSizeCornerSize

The recommended size for a Pressed button when animated.

UncheckedCornerSize

Added in 1.0.0-alpha26
val UncheckedCornerSizeCornerSize

The recommended size for an Unchecked button when animated.

defaultButtonTextStyle

Added in 1.0.0-alpha26
val defaultButtonTextStyleTextStyle

The default text style applied for text toggle buttons.

extraLargeButtonTextStyle

Added in 1.0.0-alpha26
val extraLargeButtonTextStyleTextStyle

The recommended text style for an extra large text toggle button.

largeButtonTextStyle

Added in 1.0.0-alpha26
val largeButtonTextStyleTextStyle

The recommended text style for a large text toggle button.

pressedShape

Added in 1.0.0-alpha26
val pressedShapeCornerBasedShape

Recommended pressed Shape for TextToggleButton.

shape

Added in 1.0.0-alpha26
val shapeRoundedCornerShape

Recommended Shape for TextToggleButton.