TextToggleButtonDefaults

object TextToggleButtonDefaults


Contains the default values used by TextToggleButton.

Summary

Public functions

TextToggleButtonShapes

Creates a Shape with a animation between two CornerBasedShapes.

TextToggleButtonShapes

Creates a TextToggleButtonShapes with a static shape.

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

TextToggleButtonShapes
@Composable
variantAnimatedShapes(
    uncheckedShape: CornerBasedShape,
    checkedShape: CornerBasedShape,
    pressedShapeCornerSizeFraction: Float
)

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

Public properties

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.

Float

Recommended pressed shape corner size fraction for variantAnimatedShapes.

CornerBasedShape

Recommended checked Shape for TextToggleButton.

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

animatedShapes

Added in 1.0.0-alpha30
@Composable
fun animatedShapes(
    shape: CornerBasedShape = TextToggleButtonDefaults.shape,
    pressedShape: CornerBasedShape = TextToggleButtonDefaults.pressedShape
): TextToggleButtonShapes

Creates a Shape with a animation between two CornerBasedShapes.

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

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

var checked by remember { mutableStateOf(true) }
TextToggleButton(
    checked = checked,
    onCheckedChange = { checked = !checked },
    shapes = TextToggleButtonDefaults.animatedShapes(),
) {
    Text(text = if (checked) "On" else "Off")
}
Parameters
shape: CornerBasedShape = TextToggleButtonDefaults.shape

The normal shape of the TextToggleButton.

pressedShape: CornerBasedShape = TextToggleButtonDefaults.pressedShape

The pressed shape of the TextToggleButton.

shapes

Added in 1.0.0-alpha30
@Composable
fun shapes(shape: Shape = TextToggleButtonDefaults.shape): TextToggleButtonShapes

Creates a TextToggleButtonShapes with a static shape.

Parameters
shape: Shape = TextToggleButtonDefaults.shape

The normal shape of the TextToggleButton.

textToggleButtonColors

Added in 1.0.0-alpha30
@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

variantAnimatedShapes

Added in 1.0.0-alpha30
@Composable
fun variantAnimatedShapes(
    uncheckedShape: CornerBasedShape = shape,
    checkedShape: CornerBasedShape = this.checkedShape,
    pressedShapeCornerSizeFraction: Float = PressedShapeCornerSizeFraction
): TextToggleButtonShapes

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

var checked by remember { mutableStateOf(true) }
TextToggleButton(
    checked = checked,
    onCheckedChange = { checked = !checked },
    shapes = TextToggleButtonDefaults.variantAnimatedShapes()
) {
    Text(text = if (checked) "On" else "Off")
}
Parameters
uncheckedShape: CornerBasedShape = shape

the unchecked shape.

checkedShape: CornerBasedShape = this.checkedShape

the checked shape.

pressedShapeCornerSizeFraction: Float = PressedShapeCornerSizeFraction

The fraction to apply to the uncheckedShape and checkedShape corner sizes, when the button is pressed. For example, the button shape animates from uncheckedShape to a new CornerBasedShape with corner size = uncheckedShape's corner size * pressedCornerShapeFraction. By default, the button corners are reduced in size when pressed, so that the button becomes more square.

Public properties

DefaultButtonSize

Added in 1.0.0-alpha30
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-alpha30
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-alpha30
val LargeButtonSizeDp

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

PressedShapeCornerSizeFraction

Added in 1.0.0-alpha30
val PressedShapeCornerSizeFractionFloat

Recommended pressed shape corner size fraction for variantAnimatedShapes. This fraction will be applied to checked and unchecked shapes to generate the checkedPressed and uncheckedPressed shapes.

checkedShape

Added in 1.0.0-alpha30
val checkedShapeCornerBasedShape

Recommended checked Shape for TextToggleButton.

defaultButtonTextStyle

Added in 1.0.0-alpha30
val defaultButtonTextStyleTextStyle

The default text style applied for text toggle buttons.

extraLargeButtonTextStyle

Added in 1.0.0-alpha30
val extraLargeButtonTextStyleTextStyle

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

largeButtonTextStyle

Added in 1.0.0-alpha30
val largeButtonTextStyleTextStyle

The recommended text style for a large text toggle button.

pressedShape

Added in 1.0.0-alpha30
val pressedShapeCornerBasedShape

Recommended pressed Shape for TextToggleButton.

shape

Added in 1.0.0-alpha30
val shapeRoundedCornerShape

Recommended Shape for TextToggleButton.