Android 12 Developer Preview is here! Try it out, and give us your feedback!

SwitchColors

@Stable interface SwitchColors
androidx.compose.material.SwitchColors

Represents the colors used by a Switch in different states

See SwitchDefaults.colors for the default implementation that follows Material specifications.

Summary

Public methods
abstract State<Color>
thumbColor(enabled: Boolean, checked: Boolean)

Represents the color used for the switch's thumb, depending on enabled and checked.

abstract State<Color>
trackColor(enabled: Boolean, checked: Boolean)

Represents the color used for the switch's track, depending on enabled and checked.

Public methods

thumbColor

@Composable abstract fun thumbColor(
    enabled: Boolean,
    checked: Boolean
): State<Color>

Represents the color used for the switch's thumb, depending on enabled and checked.

Parameters
enabled: Boolean whether the Switch is enabled or not
checked: Boolean whether the Switch is checked or not

trackColor

@Composable abstract fun trackColor(
    enabled: Boolean,
    checked: Boolean
): State<Color>

Represents the color used for the switch's track, depending on enabled and checked.

Parameters
enabled: Boolean whether the Switch is enabled or not
checked: Boolean whether the Switch is checked or not