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

Added in 1.5.0
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

Added in 1.6.0
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 background: Color

error

Added in 1.0.0
val error: Color

onBackground

Added in 1.0.0
val onBackground: Color

onError

Added in 1.0.0
val onError: Color

onPrimary

Added in 1.0.0
val onPrimary: Color

onSecondary

Added in 1.0.0
val onSecondary: Color

onSurface

Added in 1.0.0
val onSurface: Color

onSurfaceVariant

Added in 1.0.0
val onSurfaceVariant: Color

primary

Added in 1.0.0
val primary: Color

primaryVariant

Added in 1.0.0
val primaryVariant: Color

secondary

Added in 1.0.0
val secondary: Color

secondaryVariant

Added in 1.0.0
val secondaryVariant: Color

surface

Added in 1.0.0
val surface: Color

Extension functions

Colors.contentColorFor

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