class Colors


Summary

Public constructors

Colors(
    primary: Color,
    primaryVariant: Color,
    secondary: Color,
    secondaryVariant: Color,
    background: Color,
    surface: Color,
    error: Color,
    onPrimary: Color,
    onSecondary: Color,
    onBackground: Color,
    onSurface: Color,
    onSurfaceVariant: Color,
    onError: Color
)

Public functions

Colors
copy(
    primary: Color,
    primaryVariant: Color,
    secondary: Color,
    secondaryVariant: Color,
    background: Color,
    surface: Color,
    error: Color,
    onPrimary: Color,
    onSecondary: Color,
    onBackground: Color,
    onSurface: Color,
    onSurfaceVariant: Color,
    onError: Color
)

Returns a copy of this Colors, optionally overriding some of the values.

open String

Extension functions

Color
Colors.contentColorFor(backgroundColor: Color)

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

Public constructors

Colors

Colors(
    primary: Color = Color(0xFFAECBFA),
    primaryVariant: Color = Color(0xFF8AB4F8),
    secondary: Color = Color(0xFFFDE293),
    secondaryVariant: Color = Color(0xFF594F33),
    background: Color = Color.Black,
    surface: Color = Color(0xFF303133),
    error: Color = Color(0xFFEE675C),
    onPrimary: Color = Color(0xFF303133),
    onSecondary: Color = Color(0xFF303133),
    onBackground: Color = Color.White,
    onSurface: Color = Color.White,
    onSurfaceVariant: Color = Color(0xFFDADCE0),
    onError: Color = Color(0xFF000000)
)

Public functions

copy

fun copy(
    primary: Color = this.primary,
    primaryVariant: Color = this.primaryVariant,
    secondary: Color = this.secondary,
    secondaryVariant: Color = this.secondaryVariant,
    background: Color = this.background,
    surface: Color = this.surface,
    error: Color = this.error,
    onPrimary: Color = this.onPrimary,
    onSecondary: Color = this.onSecondary,
    onBackground: Color = this.onBackground,
    onSurface: Color = this.onSurface,
    onSurfaceVariant: Color = this.onSurfaceVariant,
    onError: Color = this.onError
): Colors

Returns a copy of this Colors, optionally overriding some of the values.

toString

open fun toString(): String

Public properties

background

Added in 1.0.0
val backgroundColor

error

Added in 1.0.0
val errorColor

onBackground

Added in 1.0.0
val onBackgroundColor

onError

Added in 1.0.0
val onErrorColor

onPrimary

Added in 1.0.0
val onPrimaryColor

onSecondary

Added in 1.0.0
val onSecondaryColor

onSurface

Added in 1.0.0
val onSurfaceColor

onSurfaceVariant

Added in 1.0.0
val onSurfaceVariantColor

primary

Added in 1.0.0
val primaryColor

primaryVariant

Added in 1.0.0
val primaryVariantColor

secondary

Added in 1.0.0
val secondaryColor

secondaryVariant

Added in 1.0.0
val secondaryVariantColor

surface

Added in 1.0.0
val surfaceColor

Extension functions

fun Colors.contentColorFor(backgroundColor: Color): Color

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.

See also
contentColorFor