IconToggleButtonDefaults

object IconToggleButtonDefaults


Contains the default values used by IconToggleButton.

Summary

Public functions

IconToggleButtonShapes

Creates a Shape with a animation between two CornerBasedShapes.

Dp
iconSizeFor(buttonSize: Dp)

Recommended icon size for a given icon toggle button size.

IconToggleButtonColors

Creates an IconToggleButtonColors for a IconToggleButton

IconToggleButtonColors
@Composable
iconToggleButtonColors(
    checkedContainerColor: Color,
    checkedContentColor: Color,
    uncheckedContainerColor: Color,
    uncheckedContentColor: Color,
    disabledCheckedContainerColor: Color,
    disabledCheckedContentColor: Color,
    disabledUncheckedContainerColor: Color,
    disabledUncheckedContentColor: Color
)

Creates a IconToggleButtonColors for a IconToggleButton

IconToggleButtonShapes

Creates a IconToggleButtonShapes with a static shape.

IconToggleButtonShapes
@Composable
variantAnimatedShapes(
    uncheckedCornerSize: CornerBasedShape,
    checkedCornerSize: CornerBasedShape,
    pressedCornerSize: CornerBasedShape
)

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 icon toggle buttons.

Dp

The default size of an icon when used inside an icon toggle button of size DefaultButtonSize.

Dp

The recommended size for an extra icon large toggle button.

Dp

The size of an icon when used inside an icon toggle button with size ExtraLargeButtonSize.

Dp

The recommended size for a large icon toggle button.

Dp

The size of an icon when used inside an icon toggle button with size LargeButtonSize.

Dp

The recommended size for a small button.

Dp

The recommended size of an icon when used inside an icon toggle button with size SmallButtonSize.

CornerBasedShape

Recommended checked Shape for IconToggleButton.

CornerBasedShape

Recommended pressed Shape for IconToggleButton.

RoundedCornerShape

Recommended Shape for IconToggleButton.

Public functions

animatedShapes

Added in 1.0.0-alpha28
@Composable
fun animatedShapes(
    shape: CornerBasedShape = IconToggleButtonDefaults.shape,
    pressedShape: CornerBasedShape = IconToggleButtonDefaults.pressedShape
): IconToggleButtonShapes

Creates a Shape with a animation between two CornerBasedShapes.

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

import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Favorite
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.wear.compose.material3.Icon
import androidx.wear.compose.material3.IconToggleButton
import androidx.wear.compose.material3.IconToggleButtonDefaults

var checked by remember { mutableStateOf(true) }
IconToggleButton(
    checked = checked,
    onCheckedChange = { checked = !checked },
    shapes = IconToggleButtonDefaults.animatedShapes(),
) {
    Icon(imageVector = Icons.Filled.Favorite, contentDescription = "Favorite icon")
}
Parameters
shape: CornerBasedShape = IconToggleButtonDefaults.shape

The normal shape of the IconToggleButton.

pressedShape: CornerBasedShape = IconToggleButtonDefaults.pressedShape

The pressed shape of the IconToggleButton.

iconSizeFor

fun iconSizeFor(buttonSize: Dp): Dp

Recommended icon size for a given icon toggle button size.

Ensures that the minimum recommended icon size is applied.

Examples: for size SmallButtonSize, returns SmallIconSize, for size ExtraLargeButtonSize returns ExtraLargeIconSize.

Parameters
buttonSize: Dp

The size of the icon toggle button

iconToggleButtonColors

Added in 1.0.0-alpha28
@Composable
fun iconToggleButtonColors(): IconToggleButtonColors

Creates an IconToggleButtonColors for a IconToggleButton

  • by default, a colored background with a contrasting content color.

If the button is disabled, then the colors will have an alpha (DisabledContentAlpha and DisabledContainerAlpha) value applied.

iconToggleButtonColors

@Composable
fun iconToggleButtonColors(
    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
): IconToggleButtonColors

Creates a IconToggleButtonColors for a IconToggleButton

  • by default, a colored background with a contrasting content color.

If the button is disabled, then the colors will have an alpha (DisabledContentAlpha and DisabledContainerAlpha) value applied.

Parameters
checkedContainerColor: Color = Color.Unspecified

The container color of this IconToggleButton when enabled and checked

checkedContentColor: Color = Color.Unspecified

The content color of this IconToggleButton when enabled and checked

uncheckedContainerColor: Color = Color.Unspecified

The container color of this IconToggleButton when enabled and unchecked

uncheckedContentColor: Color = Color.Unspecified

The content color of this IconToggleButton when enabled and unchecked

disabledCheckedContainerColor: Color = Color.Unspecified

The container color of this IconToggleButton when checked and not enabled

disabledCheckedContentColor: Color = Color.Unspecified

The content color of this IconToggleButton when checked and not enabled

disabledUncheckedContainerColor: Color = Color.Unspecified

The container color of this IconToggleButton when unchecked and not enabled

disabledUncheckedContentColor: Color = Color.Unspecified

The content color of this IconToggleButton when unchecked and not enabled

shapes

Added in 1.0.0-alpha28
@Composable
fun shapes(shape: Shape = IconToggleButtonDefaults.shape): IconToggleButtonShapes

Creates a IconToggleButtonShapes with a static shape.

Parameters
shape: Shape = IconToggleButtonDefaults.shape

The normal shape of the IconToggleButton.

variantAnimatedShapes

Added in 1.0.0-alpha28
@Composable
fun variantAnimatedShapes(
    uncheckedCornerSize: CornerBasedShape = shape,
    checkedCornerSize: CornerBasedShape = checkedShape,
    pressedCornerSize: CornerBasedShape = pressedShape
): IconToggleButtonShapes

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

A simple icon 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.Icon
import androidx.wear.compose.material3.IconToggleButton
import androidx.wear.compose.material3.IconToggleButtonDefaults
import androidx.wear.compose.material3.samples.icons.WifiOffIcon
import androidx.wear.compose.material3.samples.icons.WifiOnIcon

var checked by remember { mutableStateOf(true) }
IconToggleButton(
    checked = checked,
    onCheckedChange = { checked = !checked },
    shapes = IconToggleButtonDefaults.variantAnimatedShapes(),
) {
    if (checked) {
        WifiOnIcon()
    } else {
        WifiOffIcon()
    }
}
Parameters
uncheckedCornerSize: CornerBasedShape = shape

the size of the corner when unchecked.

checkedCornerSize: CornerBasedShape = checkedShape

the size of the corner when checked.

pressedCornerSize: CornerBasedShape = pressedShape

the size of the corner when pressed.

Public properties

DefaultButtonSize

Added in 1.0.0-alpha28
val DefaultButtonSizeDp

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

DefaultIconSize

Added in 1.0.0-alpha28
val DefaultIconSizeDp

The default size of an icon when used inside an icon toggle button of size DefaultButtonSize. Use iconSizeFor to easily determine the icon size.

ExtraLargeButtonSize

Added in 1.0.0-alpha28
val ExtraLargeButtonSizeDp

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

ExtraLargeIconSize

Added in 1.0.0-alpha28
val ExtraLargeIconSizeDp

The size of an icon when used inside an icon toggle button with size ExtraLargeButtonSize. Use iconSizeFor to easily determine the icon size.

LargeButtonSize

Added in 1.0.0-alpha28
val LargeButtonSizeDp

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

LargeIconSize

Added in 1.0.0-alpha28
val LargeIconSizeDp

The size of an icon when used inside an icon toggle button with size LargeButtonSize. Use iconSizeFor to easily determine the icon size.

SmallButtonSize

Added in 1.0.0-alpha28
val SmallButtonSizeDp

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

SmallIconSize

Added in 1.0.0-alpha28
val SmallIconSizeDp

The recommended size of an icon when used inside an icon toggle button with size SmallButtonSize. Use iconSizeFor to easily determine the icon size.

checkedShape

Added in 1.0.0-alpha28
val checkedShapeCornerBasedShape

Recommended checked Shape for IconToggleButton.

pressedShape

Added in 1.0.0-alpha28
val pressedShapeCornerBasedShape

Recommended pressed Shape for IconToggleButton.

shape

Added in 1.0.0-alpha28
val shapeRoundedCornerShape

Recommended Shape for IconToggleButton.