theming-material / Class

SchemeStaticColorBuilder

Implementation of ThemeBuilder that generates hex color tokens for Material Design static colors (aka. custom colors).

Notes

A static color consists of 4 roles. Suppose the name of the static color is "success", then there will be "success", "on-success", "success-container", and "on-success-container" roles.

A non-empty name must be assigned to this builder. The name assigned to this builder will be used as the prefix to the generated tokens. When the name is "scheme", the generated tokens will be "scheme-success", "scheme-on-success", etc.

When assigned the same name with SchemeBuilder, this builder can supplement additional static colors to the main color roles generated by SchemeBuilder.

See Also

Properties

NameTypeDescription
hctFormatter
p
HctFormatter

Methods

build()

implements ThemeBuilder

No documentation has been provided.

Presentation
Parameters
Returns
protected

getStaticColorTones()

No documentation has been provided.

Presentation
protected getStaticColorTones(mode: SchemeMode): Record<"color" | "onColor" | "colorContainer" | "onColorContainer", number>;
Parameters
NameTypeDescription
mode
SchemeMode
Returns
Record<"color" | "onColor" | "colorContainer" | "onColorContainer", number>

Example usage

provideTheme(
  withThemeBuilder("scheme", SchemeBuilder, {
    type: SchemeTonalSpot,
    source: Hct.fromInt(0x33bdff),
    mode: SchemeMode.Light,
    contrast: SchemeContrastLevel.Standard,
  }),
  withThemeBuilder("scheme", SchemeStaticColorBuilder, {
    name: "success",
    source: Hct.fromInt(0x8cb84a),
    mode: SchemeMode.Light,
  }),
  withThemeBuilder("scheme", SchemeStaticColorBuilder, {
    name: "warning",
    source: Hct.fromInt(0xd6913e),
    mode: SchemeMode.Light,
  }),
),