ToggleButtonColors

Class

Common
class ToggleButtonColors(
    val containerColor: Color,
    val contentColor: Color,
    val disabledContainerColor: Color,
    val disabledContentColor: Color,
    val checkedContainerColor: Color,
    val checkedContentColor: Color,
)

Represents the container and content colors used in a toggle button in different states.

  • See ToggleButtonDefaults.toggleButtonColors for the default colors used in a ToggleButton.
  • See ToggleButtonDefaults.elevatedToggleButtonColors for the default colors used in a ElevatedToggleButton.
  • See ToggleButtonDefaults.tonalToggleButtonColors for the default colors used in a TonalToggleButton.
  • See ToggleButtonDefaults.outlinedToggleButtonColors for the default colors used in a OutlinedToggleButton.

Parameters

containerColorthe container color of this ToggleButton when enabled.
contentColorthe content color of this ToggleButton when enabled.
disabledContainerColorthe container color of this ToggleButton when not enabled.
disabledContentColorthe content color of this ToggleButton when not enabled.
checkedContainerColorthe container color of this ToggleButton when checked.
checkedContentColorthe content color of this ToggleButton when checked.

Functions

fun copy(
        containerColor: Color = this.containerColor,
        contentColor: Color = this.contentColor,
        disabledContainerColor: Color = this.disabledContainerColor,
        disabledContentColor: Color = this.disabledContentColor,
        checkedContainerColor: Color = this.checkedContainerColor,
        checkedContentColor: Color = this.checkedContentColor,
    ) =
        ToggleButtonColors(
            containerColor.takeOrElse { this.containerColor },
            contentColor.takeOrElse { this.contentColor },
            disabledContainerColor.takeOrElse { this.disabledContainerColor },
            disabledContentColor.takeOrElse { this.disabledContentColor },
            checkedContainerColor.takeOrElse { this.checkedContainerColor },
            checkedContentColor.takeOrElse { this.checkedContentColor },
        )

Returns a copy of this ToggleButtonColors, optionally overriding some of the values. This uses the Color.Unspecified to mean “use the value from the source”