ColorsKt

public final class ColorsKt


Summary

Public methods

static final @NonNull Color
ColorsKt.contentColorFor(
    @NonNull Colors receiver,
    @NonNull Color backgroundColor
)

The Material color system contains pairs of colors that are typically used for the background and content color inside a component.

static final @Composable @NonNull Color
contentColorFor(@NonNull Color backgroundColor)

The Material color system contains pairs of colors that are typically used for the background and content color inside a component.

Public methods

ColorsKt.contentColorFor

@NonNull
public static final Color ColorsKt.contentColorFor(
    @NonNull Colors receiver,
    @NonNull Color backgroundColor
)

The Material color system contains pairs of colors that are typically used for the background and content color inside a component. For example, a Button typically uses primary for its background, and onPrimary for the color of its content (usually text or iconography).

This function tries to match the provided backgroundColor to a 'background' color in this Colors, and then will return the corresponding color used for content. For example, when backgroundColor is Colors.primary, this will return Colors.onPrimary.

If backgroundColor does not match a background color in the theme, this will return Color.Unspecified.

Returns
Color

the matching content color for backgroundColor. If backgroundColor is not present in the theme's Colors, then returns Color.Unspecified.

contentColorFor

@Composable
@NonNull
public static final @Composable Color contentColorFor(@NonNull Color backgroundColor)

The Material color system contains pairs of colors that are typically used for the background and content color inside a component. For example, a Button typically uses primary for its background, and onPrimary for the color of its content (usually text or iconography).

This function tries to match the provided backgroundColor to a 'background' color in this Colors, and then will return the corresponding color used for content. For example, when backgroundColor is Colors.primary, this will return Colors.onPrimary.

If backgroundColor does not match a background color in the theme, this will return the current value of LocalContentColor as a best-effort color.

Returns
@Composable Color

the matching content color for backgroundColor. If backgroundColor is not present in the theme's Colors, then returns the current value of LocalContentColor.

See also
contentColorFor