MenuItemColors

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

MenuItemColors

Class

Common
class MenuItemColors
@ExperimentalMaterial3ExpressiveApi
constructor(
    val textColor: Color,
    val leadingIconColor: Color,
    val trailingIconColor: Color,
    val disabledTextColor: Color,
    val disabledLeadingIconColor: Color,
    val disabledTrailingIconColor: Color,
    containerColor: Color,
    disabledContainerColor: Color,
    selectedTextColor: Color,
    selectedLeadingIconColor: Color,
    selectedTrailingIconColor: Color,
    selectedContainerColor: Color,
)

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

Parameters

textColorthe text color of this DropdownMenuItemContent when enabled
leadingIconColorthe leading icon color of this DropdownMenuItemContent when enabled
trailingIconColorthe trailing icon color of this DropdownMenuItemContent when enabled
disabledTextColorthe text color of this DropdownMenuItemContent when not enabled
disabledLeadingIconColorthe leading icon color of this DropdownMenuItemContent when not enabled
disabledTrailingIconColorthe trailing icon color of this DropdownMenuItemContent when not enabled
containerColorthe container color of this menu item when enabled and unselected
disabledContainerColorthe container color of this menu item when not enabled
selectedTextColorthe text color of this menu item when enabled and selected
selectedContainerColorthe container color of this menu item when enabled and selected
selectedLeadingIconColorthe leading icon color of this menu item when enabled and selected
selectedTrailingIconColorthe trailing icon color of this menu item when enabled and selected

Secondary Constructors

constructor(
    textColor: Color,
    leadingIconColor: Color,
    trailingIconColor: Color,
    disabledTextColor: Color,
    disabledLeadingIconColor: Color,
    disabledTrailingIconColor: Color,
) : this(
    textColor = textColor,
    leadingIconColor = leadingIconColor,
    trailingIconColor = trailingIconColor,
    disabledTextColor = disabledTextColor,
    disabledLeadingIconColor = disabledLeadingIconColor,
    disabledTrailingIconColor = disabledTrailingIconColor,
    containerColor = Color.Unspecified,
    disabledContainerColor = Color.Unspecified,
    selectedTextColor = Color.Unspecified,
    selectedLeadingIconColor = Color.Unspecified,
    selectedTrailingIconColor = Color.Unspecified,
    selectedContainerColor = Color.Unspecified,
)

Creates an instance with colors for a standard menu item.

This constructor is used for DropdownMenuItem.

Parameters

textColorthe text color of this menu item when enabled
leadingIconColorthe leading icon color of this menu item when enabled
trailingIconColorthe trailing icon color of this menu item when enabled
disabledTextColorthe text color of this menu item when not enabled
disabledLeadingIconColorthe leading icon color of this menu item when not enabled
disabledTrailingIconColorthe trailing icon color of this menu item when not enabled

Properties

Common
@ExperimentalMaterial3ExpressiveApi val : Color

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

Common
@ExperimentalMaterial3ExpressiveApi val disabledContainerColor = disabledContainerColor

The container color of this menu item when not enabled

Common
@ExperimentalMaterial3ExpressiveApi val : Color

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

Common
@ExperimentalMaterial3ExpressiveApi val : Color

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

Common
@ExperimentalMaterial3ExpressiveApi
val : Color

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

Common
@ExperimentalMaterial3ExpressiveApi
val : Color

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

Functions

@ExperimentalMaterial3ExpressiveApi
    fun copy(
        textColor: Color = this.textColor,
        containerColor: Color = this.containerColor,
        leadingIconColor: Color = this.leadingIconColor,
        trailingIconColor: Color = this.trailingIconColor,
        disabledTextColor: Color = this.disabledTextColor,
        disabledContainerColor: Color = this.disabledContainerColor,
        disabledLeadingIconColor: Color = this.disabledLeadingIconColor,
        disabledTrailingIconColor: Color = this.disabledTrailingIconColor,
        selectedTextColor: Color = this.selectedTextColor,
        selectedContainerColor: Color = this.selectedContainerColor,
        selectedLeadingIconColor: Color = this.selectedLeadingIconColor,
        selectedTrailingIconColor: Color = this.selectedTrailingIconColor,
    ) =
        MenuItemColors(
            textColor.takeOrElse { this.textColor },
            leadingIconColor.takeOrElse { this.leadingIconColor },
            trailingIconColor.takeOrElse { this.trailingIconColor },
            disabledTextColor.takeOrElse { this.disabledTextColor },
            disabledLeadingIconColor.takeOrElse { this.disabledLeadingIconColor },
            disabledTrailingIconColor.takeOrElse { this.disabledTrailingIconColor },
            containerColor.takeOrElse { this.containerColor },
            disabledContainerColor.takeOrElse { this.disabledContainerColor },
            selectedTextColor.takeOrElse { this.selectedTextColor },
            selectedLeadingIconColor.takeOrElse { this.selectedLeadingIconColor },
            selectedTrailingIconColor.takeOrElse { this.selectedTrailingIconColor },
            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”

fun copy(
        textColor: Color = this.textColor,
        leadingIconColor: Color = this.leadingIconColor,
        trailingIconColor: Color = this.trailingIconColor,
        disabledTextColor: Color = this.disabledTextColor,
        disabledLeadingIconColor: Color = this.disabledLeadingIconColor,
        disabledTrailingIconColor: Color = this.disabledTrailingIconColor,
    ) =
        MenuItemColors(
            textColor.takeOrElse { this.textColor },
            leadingIconColor.takeOrElse { this.leadingIconColor },
            trailingIconColor.takeOrElse { this.trailingIconColor },
            disabledTextColor.takeOrElse { this.disabledTextColor },
            disabledLeadingIconColor.takeOrElse { this.disabledLeadingIconColor },
            disabledTrailingIconColor.takeOrElse { this.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”