ButtonColors

Class

Common
class ButtonColors
constructor(
    val containerColor: Color,
    val contentColor: Color,
    val disabledContainerColor: Color,
    val disabledContentColor: Color,
)

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

  • See ButtonDefaults.buttonColors for the default colors used in a Button.
  • See ButtonDefaults.elevatedButtonColors for the default colors used in a ElevatedButton.
  • See ButtonDefaults.textButtonColors for the default colors used in a TextButton.

Parameters

containerColorthe container color of this Button when enabled.
contentColorthe content color of this Button when enabled.
disabledContainerColorthe container color of this Button when not enabled.
disabledContentColorthe content color of this Button when not enabled. @constructor create an instance with arbitrary colors.

Functions

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

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