ColorScheme
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( |
Public functions |
|
|---|---|
ColorScheme |
copy(Returns a copy of this Colors, optionally overriding some of the values. |
open String |
toString() |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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
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
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.
Public properties
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.
onErrorContainer
val onErrorContainer: Color
Color used for text and icons on the errorContainer 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.
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.
primary
val primary: Color
The primary color is the color displayed most frequently across your app’s screens and components.
secondary
val secondary: Color
The secondary color provides more ways to accent and distinguish your product.
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.
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
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 |
| See also | |
|---|---|
contentColorFor |