Start native apps faster with the Composables CLI ->
Class

MenuItemColors

Represents the text and icon colors used in a menu item at different states.

Source set: Common
class MenuItemColors(
    val textColor: Color,
    val leadingIconColor: Color,
    @Deprecated("Use trailingContentColor instead.", ReplaceWith("trailingContentColor"))
    val trailingIconColor: Color,
    val disabledTextColor: Color,
    val disabledLeadingIconColor: Color,
    @Deprecated(
        "Use disabledTrailingContentColor instead.",
        ReplaceWith("disabledTrailingContentColor"),
    )
    val disabledTrailingIconColor: Color,
)

Represents the text and icon colors used in a menu item at different states.

Parameters

textColor the text color of this DropdownMenuItem when enabled and unselected / unchecked.
leadingIconColor the leading icon color of this DropdownMenuItem when enabled and unselected / unchecked.
trailingIconColor the trailing icon color of this DropdownMenuItem when enabled and unselected / unchecked.
disabledTextColor the text color of this DropdownMenuItem when not enabled
disabledLeadingIconColor the leading icon color of this DropdownMenuItem when not enabled
disabledTrailingIconColor the trailing icon color of this DropdownMenuItem when not enabled

Secondary Constructors

// Secondary constructor to initialize all 12 properties
constructor(
    textColor: Color,
    leadingIconColor: Color,
    trailingIconColor: Color,
    disabledTextColor: Color,
    disabledLeadingIconColor: Color,
    disabledTrailingIconColor: Color,
    containerColor: Color,
    disabledContainerColor: Color,
    selectedTextColor: Color,
    selectedLeadingIconColor: Color,
    selectedTrailingIconColor: Color,
    selectedContainerColor: Color,
) : this(
    textColor = textColor,
    leadingIconColor = leadingIconColor,
    trailingIconColor = trailingIconColor,
    disabledTextColor = disabledTextColor,
    disabledLeadingIconColor = disabledLeadingIconColor,
    disabledTrailingIconColor = disabledTrailingIconColor,
) {
    this.containerColor = containerColor
    this.disabledContainerColor = disabledContainerColor
    this.selectedTextColor = selectedTextColor
    this.selectedContainerColor = selectedContainerColor
    this.selectedLeadingIconColor = selectedLeadingIconColor
    this.selectedTrailingContentColor = selectedTrailingIconColor
}

Properties

containerColor

Source set: Common
var containerColor: Color

The container color of this menu item when enabled and unselected.

disabledContainerColor

Source set: Common
var disabledContainerColor: Color

The container color of this menu item when not enabled

selectedContainerColor

Source set: Common
var selectedContainerColor: Color

The container color of this menu item when enabled and selected.

selectedTextColor

Source set: Common
var selectedTextColor: Color

The text color of this menu item when enabled and selected.

selectedLeadingIconColor

Source set: Common
var selectedLeadingIconColor: Color

The leading icon color of this menu item when enabled and selected.

selectedTrailingContentColor

Source set: Common
var selectedTrailingContentColor: Color

The trailing content color of this menu item when enabled and selected.

selectedTrailingIconColor

Deprecated

Use selectedTrailingContentColor instead.

Source set: Common
val selectedTrailingIconColor: Color

The trailing icon color of this menu item when enabled and selected.

trailingContentColor

Source set: Common
val trailingContentColor: Color

The trailing content color of this menu item when enabled and unselected.

disabledTrailingContentColor

Source set: Common
val disabledTrailingContentColor: Color

The trailing content color of this menu item when not enabled.

Functions

copyLegacy

fun copyLegacy(
        textColor: Color = this.textColor,
        leadingIconColor: Color = this.leadingIconColor,
        trailingIconColor: Color = this.trailingContentColor,
        disabledTextColor: Color = this.disabledTextColor,
        disabledLeadingIconColor: Color = this.disabledLeadingIconColor,
        disabledTrailingIconColor: Color = this.disabledTrailingContentColor,
    ) =
        copy(
            textColor = textColor,
            leadingIconColor = leadingIconColor,
            trailingContentColor = trailingIconColor,
            disabledTextColor = disabledTextColor,
            disabledLeadingIconColor = disabledLeadingIconColor,
            disabledTrailingContentColor = disabledTrailingIconColor,
        )

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

copyLegacy

fun copyLegacy(
        textColor: Color = this.textColor,
        containerColor: Color = this.containerColor,
        leadingIconColor: Color = this.leadingIconColor,
        trailingIconColor: Color = this.trailingContentColor,
        disabledTextColor: Color = this.disabledTextColor,
        disabledContainerColor: Color = this.disabledContainerColor,
        disabledLeadingIconColor: Color = this.disabledLeadingIconColor,
        disabledTrailingIconColor: Color = this.disabledTrailingContentColor,
        selectedTextColor: Color = this.selectedTextColor,
        selectedContainerColor: Color = this.selectedContainerColor,
        selectedLeadingIconColor: Color = this.selectedLeadingIconColor,
        selectedTrailingIconColor: Color = this.selectedTrailingContentColor,
    ) =
        MenuItemColors(
            textColor.takeOrElse { this.textColor },
            leadingIconColor.takeOrElse { this.leadingIconColor },
            trailingContentColor.takeOrElse { this.trailingContentColor },
            disabledTextColor.takeOrElse { this.disabledTextColor },
            disabledLeadingIconColor.takeOrElse { this.disabledLeadingIconColor },
            disabledTrailingIconColor.takeOrElse { this.disabledTrailingContentColor },
            containerColor.takeOrElse { this.containerColor },
            disabledContainerColor.takeOrElse { this.disabledContainerColor },
            selectedTextColor.takeOrElse { this.selectedTextColor },
            selectedLeadingIconColor.takeOrElse { this.selectedLeadingIconColor },
            selectedTrailingIconColor.takeOrElse { this.selectedTrailingContentColor },
            selectedContainerColor.takeOrElse { this.selectedContainerColor },
        )

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

copy

fun copy(
        textColor: Color = this.textColor,
        containerColor: Color = this.containerColor,
        leadingIconColor: Color = this.leadingIconColor,
        trailingContentColor: Color = this.trailingContentColor,
        disabledTextColor: Color = this.disabledTextColor,
        disabledContainerColor: Color = this.disabledContainerColor,
        disabledLeadingIconColor: Color = this.disabledLeadingIconColor,
        disabledTrailingContentColor: Color = this.disabledTrailingContentColor,
        selectedTextColor: Color = this.selectedTextColor,
        selectedContainerColor: Color = this.selectedContainerColor,
        selectedLeadingIconColor: Color = this.selectedLeadingIconColor,
        selectedTrailingContentColor: Color = this.selectedTrailingContentColor,
    ) =
        MenuItemColors(
            textColor = textColor.takeOrElse { this.textColor },
            leadingIconColor = leadingIconColor.takeOrElse { this.leadingIconColor },
            trailingIconColor = trailingContentColor.takeOrElse { this.trailingContentColor },
            disabledTextColor = disabledTextColor.takeOrElse { this.disabledTextColor },
            disabledLeadingIconColor =
                disabledLeadingIconColor.takeOrElse { this.disabledLeadingIconColor },
            disabledTrailingIconColor =
                disabledTrailingContentColor.takeOrElse { this.disabledTrailingContentColor },
            containerColor = containerColor.takeOrElse { this.containerColor },
            disabledContainerColor =
                disabledContainerColor.takeOrElse { this.disabledContainerColor },
            selectedTextColor = selectedTextColor.takeOrElse { this.selectedTextColor },
            selectedLeadingIconColor =
                selectedLeadingIconColor.takeOrElse { this.selectedLeadingIconColor },
            selectedTrailingIconColor =
                selectedTrailingContentColor.takeOrElse { this.selectedTrailingContentColor },
            selectedContainerColor =
                selectedContainerColor.takeOrElse { this.selectedContainerColor },
        )

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

copy

fun copy(
        textColor: Color = this.textColor,
        leadingIconColor: Color = this.leadingIconColor,
        trailingContentColor: Color = this.trailingContentColor,
        disabledTextColor: Color = this.disabledTextColor,
        disabledLeadingIconColor: Color = this.disabledLeadingIconColor,
        disabledTrailingContentColor: Color = this.disabledTrailingContentColor,
    ) =
        MenuItemColors(
            textColor = textColor,
            leadingIconColor = leadingIconColor,
            trailingIconColor = trailingContentColor,
            disabledTextColor = disabledTextColor,
            disabledLeadingIconColor = disabledLeadingIconColor,
            disabledTrailingIconColor = disabledTrailingContentColor,
            containerColor = Color.Unspecified,
            disabledContainerColor = Color.Unspecified,
            selectedTextColor = Color.Unspecified,
            selectedLeadingIconColor = Color.Unspecified,
            selectedTrailingIconColor = Color.Unspecified,
            selectedContainerColor = Color.Unspecified,
        )

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

Last updated: