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
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

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
containerColor the container color of this menu item when enabled and unselected / unchecked
disabledContainerColor the container color of this menu item when not enabled
selectedTextColor the text color of this menu item when enabled and selected / checked.
selectedContainerColor the container color of this menu item when enabled and selected / checked.
selectedLeadingIconColor the leading icon color of this menu item when enabled and selected / checked.
selectedTrailingIconColor the trailing icon color of this menu item when enabled and selected / checked.

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

textColor the text color of this menu item when enabled
leadingIconColor the leading icon color of this menu item when enabled
trailingIconColor the trailing icon color of this menu item when enabled
disabledTextColor the text color of this menu item when not enabled
disabledLeadingIconColor the leading icon color of this menu item when not enabled
disabledTrailingIconColor the trailing icon color of this menu item when not enabled

Properties

containerColor

Source set: Common
val : Color

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

disabledContainerColor

Source set: Common
val disabledContainerColor = disabledContainerColor

The container color of this menu item when not enabled

selectedContainerColor

Source set: Common
val : Color

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

selectedTextColor

Source set: Common
val : Color

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

selectedLeadingIconColor

Source set: Common
val : Color

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

selectedTrailingIconColor

Source set: Common
val : Color

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

Functions

copy

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”

copy

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”

Last updated: