Skip to content

bug(theming): can no longer define custom M2 palettes on v18 #29117

@JaxonWright

Description

@JaxonWright

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

17.3.10

Description

After Angular Material 18, in order to use Material 2 themes still, you need to change a bunch of Sass functions to be new m2 variants. This works fine until you try to use mat.m2-define-palette($my-custom-palette) with a non-default palette variable.

When doing this you get the following error:
'Hue "500" does not exist in palette. Available hues are: 0, 10, 20, 25, 30, 35, 40, 50, 60, 70, 80, 90, 95, 98, 99, 100, secondary, neutral, neutral-variant, error'

This makes it seem like this internal get-color-from-palette() Sass function is expecting a Material 3 Palette instead of a Material 2 Palette despite intentionally defining a Material 2 palette via mat.m2-define-palette()

My custom palette is unchanged from Angular 17, and is in the typical 50, 100..900, A100, A200, A400, A700, contrast format for a m2 palette.

Reproduction

StackBlitz link:
Steps to reproduce:
1.
2.

Expected Behavior

Retain the ability to define custom Material 2 Palettes and use them with mat.m2-define-palette()

Actual Behavior

'Hue "500" does not exist in palette. Available hues are: 0, 10, 20, 25, 30, 35, 40, 50, 60, 70, 80, 90, 95, 98, 99, 100, secondary, neutral, neutral-variant, error'

Environment

  • Angular: 18.0.0
  • CDK/Material: 18.0.0
  • Browser(s): N/A
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageThis issue needs to be triaged by the team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions