ColorScheme
A color scheme 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. There are two built-in baseline schemes, lightColorScheme and a darkColorScheme, that can be used as-is or customized.
The Material color system and custom schemes provide default values for color as a starting point for customization.
Example of extending color scheme, including implementing Fixed Accent colors:
Samples
androidx.compose.material3.samples.ColorSchemeFixedAccentColorSampleConstructors
Properties
The background color that appears behind scrollable content.
The preferred tonal color of error containers.
A color that contrasts well with inverseSurface. Useful for content that sits on top of containers that are inverseSurface.
Color to be used as a "primary" color in places where the inverse color scheme is needed, such as the button on a SnackBar.
Color used for text and icons displayed on top of the background color.
The color (and state variants) that should be used for content on top of errorContainer.
The color (and state variants) that should be used for content on top of primaryContainer.
Color used for text and icons displayed on top of the secondary color.
The color (and state variants) that should be used for content on top of secondaryContainer.
The color (and state variants) that can be used for content on top of surface.
Color used for text and icons displayed on top of the tertiary color.
The color (and state variants) that should be used for content on top of tertiaryContainer.
Utility color used for boundaries for decorative elements when strong contrast is not required.
The preferred tonal color of containers.
A tonal color to be used in containers.
A surface variant that affects containers of components, such as cards, sheets, and menus.
A surface variant for containers with higher emphasis than surfaceContainer. Use this role for content which requires more emphasis than surfaceContainer.
A surface variant for containers with higher emphasis than surfaceContainerHigh. Use this role for content which requires more emphasis than surfaceContainerHigh.
A surface variant for containers with lower emphasis than surfaceContainer. Use this role for content which requires less emphasis than surfaceContainer.
A surface variant for containers with lower emphasis than surfaceContainerLow. Use this role for content which requires less emphasis than surfaceContainerLow.
This color will be used by components that apply tonal elevation and is applied on top of surface. The higher the elevation the more this color is used.
Another option for a color with similar uses of surface.
A tonal color to be used in containers.
Functions
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).
Returns a copy of this ColorScheme, optionally overriding some of the values.
Computes the surface tonal color at different elevation levels e.g. surface1 through surface5.