ToggleButtonDefaults


Contains the default values and utility functions used by ToggleButton.

Summary

Public functions

ToggleButtonColors

Creates a ToggleButtonColors that represents the default container and content colors used in a ToggleButton.

Cmn
ToggleButtonColors
@Composable
colors(
    containerColor: Color,
    contentColor: Color,
    disabledContainerColor: Color,
    disabledContentColor: Color,
    checkedContainerColor: Color,
    checkedContentColor: Color
)

Creates a ToggleButtonColors that represents the default container and content colors used in a ToggleButton.

Cmn
PaddingValues
contentPaddingFor(
    buttonHeight: Dp,
    hasStartIcon: Boolean,
    hasEndIcon: Boolean
)

Recommended PaddingValues for a provided toggle button height.

Cmn
PaddingValues
contentPaddingFor(
    buttonSize: ToggleButtonSize,
    hasStartIcon: Boolean,
    hasEndIcon: Boolean
)

Recommended PaddingValues for a provided buttonSize.

Cmn
ToggleButtonElevation
@Composable
elevation(
    defaultElevation: Dp,
    pressedElevation: Dp,
    focusedElevation: Dp,
    hoveredElevation: Dp,
    disabledElevation: Dp
)

Creates a ToggleButtonElevation that will animate between the provided values according to the Material specification for a ToggleButton.

Cmn
ToggleButtonShapes
@Composable
shapesFor(buttonHeight: Dp)

Resolves the recommended ToggleButtonShapes for a given toggle button height.

Cmn
ToggleButtonShapes

Resolves the recommended ToggleButtonShapes for a given buttonSize.

Cmn

Public properties

Dp

The default size of an icon when used inside a ToggleButton.

Cmn
Dp

The default size of the spacing between an icon and a text when they are used inside a ToggleButton.

Cmn
Dp

The default min height applied for ToggleButton.

Cmn
Shape

The default checked shape for ToggleButton

Cmn
Shape

The default pressed shape for ToggleButton

Cmn
Shape

The default unchecked shape for ToggleButton

Cmn
ToggleButtonSize

The default ToggleButtonSize of a ToggleButton.

Cmn

Public functions

colors

@Composable
fun colors(): ToggleButtonColors

Creates a ToggleButtonColors that represents the default container and content colors used in a ToggleButton.

colors

@Composable
fun colors(
    containerColor: Color = Color.Unspecified,
    contentColor: Color = Color.Unspecified,
    disabledContainerColor: Color = Color.Unspecified,
    disabledContentColor: Color = Color.Unspecified,
    checkedContainerColor: Color = Color.Unspecified,
    checkedContentColor: Color = Color.Unspecified
): ToggleButtonColors

Creates a ToggleButtonColors that represents the default container and content colors used in a ToggleButton.

Parameters
containerColor: Color = Color.Unspecified

the container color of this ToggleButton when enabled.

contentColor: Color = Color.Unspecified

the content color of this ToggleButton when enabled.

disabledContainerColor: Color = Color.Unspecified

the container color of this ToggleButton when not enabled.

disabledContentColor: Color = Color.Unspecified

the content color of this ToggleButton when not enabled.

checkedContainerColor: Color = Color.Unspecified

the container color of this ToggleButton when checked.

checkedContentColor: Color = Color.Unspecified

the content color of this ToggleButton when checked.

contentPaddingFor

fun contentPaddingFor(
    buttonHeight: Dp,
    hasStartIcon: Boolean = false,
    hasEndIcon: Boolean = false
): PaddingValues

Recommended PaddingValues for a provided toggle button height.

The returned content padding is based on standard container height values and is not directly interpolated from the provided buttonHeight.

Parameters
buttonHeight: Dp

the height of the toggle button

hasStartIcon: Boolean = false

whether the toggle button has a leading icon

hasEndIcon: Boolean = false

whether the toggle button has a trailing icon

contentPaddingFor

fun contentPaddingFor(
    buttonSize: ToggleButtonSize,
    hasStartIcon: Boolean = false,
    hasEndIcon: Boolean = false
): PaddingValues

Recommended PaddingValues for a provided buttonSize.

The returned content padding is based on standard container height values and is not directly interpolated from the provided buttonSize.

Parameters
buttonSize: ToggleButtonSize

the ToggleButtonSize of the toggle button

hasStartIcon: Boolean = false

whether the toggle button has a leading icon

hasEndIcon: Boolean = false

whether the toggle button has a trailing icon

elevation

@Composable
fun elevation(
    defaultElevation: Dp = FilledButtonTokens.ContainerElevation,
    pressedElevation: Dp = FilledButtonTokens.PressedContainerElevation,
    focusedElevation: Dp = FilledButtonTokens.FocusedContainerElevation,
    hoveredElevation: Dp = FilledButtonTokens.HoveredContainerElevation,
    disabledElevation: Dp = FilledButtonTokens.DisabledContainerElevation
): ToggleButtonElevation

Creates a ToggleButtonElevation that will animate between the provided values according to the Material specification for a ToggleButton.

Parameters
defaultElevation: Dp = FilledButtonTokens.ContainerElevation

the elevation used when the ToggleButton is enabled, and has no other Interactions.

pressedElevation: Dp = FilledButtonTokens.PressedContainerElevation

the elevation used when this ToggleButton is enabled and pressed.

focusedElevation: Dp = FilledButtonTokens.FocusedContainerElevation

the elevation used when the ToggleButton is enabled and focused.

hoveredElevation: Dp = FilledButtonTokens.HoveredContainerElevation

the elevation used when the ToggleButton is enabled and hovered.

disabledElevation: Dp = FilledButtonTokens.DisabledContainerElevation

the elevation used when the ToggleButton is not enabled.

shapesFor

@Composable
fun shapesFor(buttonHeight: Dp): ToggleButtonShapes

Resolves the recommended ToggleButtonShapes for a given toggle button height.

The input height is categorized into a shape bucket (such as extra small, small, medium, large, or extra large) based on the closest standard button height.

Parameters
buttonHeight: Dp

height of the button used to resolve the shape bucket

shapesFor

@Composable
fun shapesFor(buttonSize: ToggleButtonSize): ToggleButtonShapes

Resolves the recommended ToggleButtonShapes for a given buttonSize.

Parameters
buttonSize: ToggleButtonSize

ToggleButtonSize used to resolve the shape bucket

Public properties

IconSize

val IconSizeDp

The default size of an icon when used inside a ToggleButton.

IconSpacing

val IconSpacingDp

The default size of the spacing between an icon and a text when they are used inside a ToggleButton.

MinHeight

val MinHeightDp

The default min height applied for ToggleButton.

Override it by applying Modifier.heightIn directly on the toggle button composable.

checkedShape

val checkedShapeShape

The default checked shape for ToggleButton

pressedShape

val pressedShapeShape

The default pressed shape for ToggleButton

shape

val shapeShape

The default unchecked shape for ToggleButton

size

val sizeToggleButtonSize

The default ToggleButtonSize of a ToggleButton.