class ColorScheme


A ColorScheme holds all the named color parameters for a MaterialTheme.

Color schemes are designed to be harmonious, ensure accessible text, and distinguish UI elements and surfaces from one another.

The Material color system and custom schemes provide default values for color as a starting point for customization.

To learn more about color schemes, see Material Design Color System.

Summary

Public constructors

ColorScheme(
    primary: Color,
    primaryDim: Color,
    primaryContainer: Color,
    onPrimary: Color,
    onPrimaryContainer: Color,
    secondary: Color,
    secondaryDim: Color,
    secondaryContainer: Color,
    onSecondary: Color,
    onSecondaryContainer: Color,
    tertiary: Color,
    tertiaryDim: Color,
    tertiaryContainer: Color,
    onTertiary: Color,
    onTertiaryContainer: Color,
    surfaceContainerLow: Color,
    surfaceContainer: Color,
    surfaceContainerHigh: Color,
    onSurface: Color,
    onSurfaceVariant: Color,
    outline: Color,
    outlineVariant: Color,
    background: Color,
    onBackground: Color,
    error: Color,
    errorDim: Color,
    errorContainer: Color,
    onError: Color,
    onErrorContainer: Color
)

Public functions

ColorScheme
copy(
    primary: Color,
    primaryDim: Color,
    primaryContainer: Color,
    onPrimary: Color,
    onPrimaryContainer: Color,
    secondary: Color,
    secondaryDim: Color,
    secondaryContainer: Color,
    onSecondary: Color,
    onSecondaryContainer: Color,
    tertiary: Color,
    tertiaryDim: Color,
    tertiaryContainer: Color,
    onTertiary: Color,
    onTertiaryContainer: Color,
    surfaceContainerLow: Color,
    surfaceContainer: Color,
    surfaceContainerHigh: Color,
    onSurface: Color,
    onSurfaceVariant: Color,
    outline: Color,
    outlineVariant: Color,
    background: Color,
    onBackground: Color,
    error: Color,
    errorDim: Color,
    errorContainer: Color,
    onError: Color,
    onErrorContainer: Color
)

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

open String

Public properties

Color

The background color that appears behind other content.

Color

Color that indicates remove, delete, close or dismiss actions, such as Swipe to Reveal.

Color

A less prominent container color than error, for components using the error state.

Color

Indicates high priority errors or emergency actions, such as safety alerts, failed dialog overlays or stop buttons.

Color

Color used for text and icons displayed on top of the background color.

Color

Color used for text and icons displayed on top of the error color.

Color

Color used for text and icons on the errorContainer color.

Color

Color used for text and icons displayed on top of the primary color.

Color

The color (and state variants) that should be used for content on top of primaryContainer.

Color

Color used for text and icons displayed on top of the secondary color.

Color

The color (and state variants) that should be used for content on top of secondaryContainer.

Color

Color used for text and icons displayed on top of the surface color.

Color

The color for secondary text and icons on top of surfaceContainer.

Color

Color used for text and icons displayed on top of the tertiary color.

Color

The color (and state variants) that should be used for content on top of tertiaryContainer.

Color

The main color for primary outline components.

Color

The secondary color for secondary outline components.

Color

The primary color is the color displayed most frequently across your app’s screens and components.

Color

is a standout container color for key components.

Color

is less prominent than primary for component backgrounds

Color

The secondary color provides more ways to accent and distinguish your product.

Color

A tonal color to be used in containers.

Color

is less prominent than secondary for component backgrounds.

Color

The main surface color that affect surfaces of components with large containment areas, such as Card and Button.

Color

A surface color used for large containment components such Card and Button with high prominence.

Color

A surface color used for large containment components such as Card and Button with low prominence.

Color

The tertiary color that can be used to balance primary and secondary colors, or bring heightened attention to an element.

Color

A tonal color to be used in containers.

Color

A less prominent tertiary color that can be used to balance primary and secondary colors, or bring heightened attention to an element.

Extension functions

Color
ColorScheme.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

ColorScheme

Added in 1.5.0
ColorScheme(
    primary: Color = ColorTokens.Primary,
    primaryDim: Color = ColorTokens.PrimaryDim,
    primaryContainer: Color = ColorTokens.PrimaryContainer,
    onPrimary: Color = ColorTokens.OnPrimary,
    onPrimaryContainer: Color = ColorTokens.OnPrimaryContainer,
    secondary: Color = ColorTokens.Secondary,
    secondaryDim: Color = ColorTokens.SecondaryDim,
    secondaryContainer: Color = ColorTokens.SecondaryContainer,
    onSecondary: Color = ColorTokens.OnSecondary,
    onSecondaryContainer: Color = ColorTokens.OnSecondaryContainer,
    tertiary: Color = ColorTokens.Tertiary,
    tertiaryDim: Color = ColorTokens.TertiaryDim,
    tertiaryContainer: Color = ColorTokens.TertiaryContainer,
    onTertiary: Color = ColorTokens.OnTertiary,
    onTertiaryContainer: Color = ColorTokens.OnTertiaryContainer,
    surfaceContainerLow: Color = ColorTokens.SurfaceContainerLow,
    surfaceContainer: Color = ColorTokens.SurfaceContainer,
    surfaceContainerHigh: Color = ColorTokens.SurfaceContainerHigh,
    onSurface: Color = ColorTokens.OnSurface,
    onSurfaceVariant: Color = ColorTokens.OnSurfaceVariant,
    outline: Color = ColorTokens.Outline,
    outlineVariant: Color = ColorTokens.OutlineVariant,
    background: Color = ColorTokens.Background,
    onBackground: Color = ColorTokens.OnBackground,
    error: Color = ColorTokens.Error,
    errorDim: Color = ColorTokens.ErrorDim,
    errorContainer: Color = ColorTokens.ErrorContainer,
    onError: Color = ColorTokens.OnError,
    onErrorContainer: Color = ColorTokens.OnErrorContainer
)

Public functions

copy

Added in 1.6.0
fun copy(
    primary: Color = this.primary,
    primaryDim: Color = this.primaryDim,
    primaryContainer: Color = this.primaryContainer,
    onPrimary: Color = this.onPrimary,
    onPrimaryContainer: Color = this.onPrimaryContainer,
    secondary: Color = this.secondary,
    secondaryDim: Color = this.secondaryDim,
    secondaryContainer: Color = this.secondaryContainer,
    onSecondary: Color = this.onSecondary,
    onSecondaryContainer: Color = this.onSecondaryContainer,
    tertiary: Color = this.tertiary,
    tertiaryDim: Color = this.tertiaryDim,
    tertiaryContainer: Color = this.tertiaryContainer,
    onTertiary: Color = this.onTertiary,
    onTertiaryContainer: Color = this.onTertiaryContainer,
    surfaceContainerLow: Color = this.surfaceContainerLow,
    surfaceContainer: Color = this.surfaceContainer,
    surfaceContainerHigh: Color = this.surfaceContainerHigh,
    onSurface: Color = this.onSurface,
    onSurfaceVariant: Color = this.onSurfaceVariant,
    outline: Color = this.outline,
    outlineVariant: Color = this.outlineVariant,
    background: Color = this.background,
    onBackground: Color = this.onBackground,
    error: Color = this.error,
    errorDim: Color = this.errorDim,
    errorContainer: Color = this.errorContainer,
    onError: Color = this.onError,
    onErrorContainer: Color = this.onErrorContainer
): ColorScheme

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

toString

open fun toString(): String

Public properties

background

val background: Color

The background color that appears behind other content.

error

val error: Color

Color that indicates remove, delete, close or dismiss actions, such as Swipe to Reveal. Added as a slightly less alarming and urgent alternative to errorContainer than the error dim color.

errorContainer

val errorContainer: Color

A less prominent container color than error, for components using the error state. Can also indicate an active error state which feels less interactive than a filled state, such as an active emergency sharing button, or on a failed overlay dialog..

errorDim

val errorDim: Color

Indicates high priority errors or emergency actions, such as safety alerts, failed dialog overlays or stop buttons.

onBackground

val onBackground: Color

Color used for text and icons displayed on top of the background color.

onError

val onError: Color

Color used for text and icons displayed on top of the error color.

onErrorContainer

val onErrorContainer: Color

Color used for text and icons on the errorContainer color.

onPrimary

val onPrimary: Color

Color used for text and icons displayed on top of the primary color.

onPrimaryContainer

val onPrimaryContainer: Color

The color (and state variants) that should be used for content on top of primaryContainer.

onSecondary

val onSecondary: Color

Color used for text and icons displayed on top of the secondary color.

onSecondaryContainer

val onSecondaryContainer: Color

The color (and state variants) that should be used for content on top of secondaryContainer.

onSurface

val onSurface: Color

Color used for text and icons displayed on top of the surface color.

onSurfaceVariant

val onSurfaceVariant: Color

The color for secondary text and icons on top of surfaceContainer.

onTertiary

val onTertiary: Color

Color used for text and icons displayed on top of the tertiary color.

onTertiaryContainer

val onTertiaryContainer: Color

The color (and state variants) that should be used for content on top of tertiaryContainer.

outline

val outline: Color

The main color for primary outline components. The outline color role adds contrast for accessibility purposes.

outlineVariant

val outlineVariant: Color

The secondary color for secondary outline components.

primary

val primary: Color

The primary color is the color displayed most frequently across your app’s screens and components.

primaryContainer

val primaryContainer: Color

is a standout container color for key components.

primaryDim

val primaryDim: Color

is less prominent than primary for component backgrounds

secondary

val secondary: Color

The secondary color provides more ways to accent and distinguish your product.

secondaryContainer

val secondaryContainer: Color

A tonal color to be used in containers.

secondaryDim

val secondaryDim: Color

is less prominent than secondary for component backgrounds.

surfaceContainer

val surfaceContainer: Color

The main surface color that affect surfaces of components with large containment areas, such as Card and Button.

surfaceContainerHigh

val surfaceContainerHigh: Color

A surface color used for large containment components such Card and Button with high prominence.

surfaceContainerLow

val surfaceContainerLow: Color

A surface color used for large containment components such as Card and Button with low prominence.

tertiary

val tertiary: Color

The tertiary color that can be used to balance primary and secondary colors, or bring heightened attention to an element.

tertiaryContainer

val tertiaryContainer: Color

A tonal color to be used in containers.

tertiaryDim

val tertiaryDim: Color

A less prominent tertiary color that can be used to balance primary and secondary colors, or bring heightened attention to an element.

Extension functions

ColorScheme.contentColorFor

fun ColorScheme.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 ColorScheme, and then will return the corresponding color used for content. For example, when backgroundColor is ColorScheme.primary, this will return ColorScheme.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 ColorScheme, then returns Color.Unspecified.

See also
contentColorFor