Search code examples
angularangular-material

Angular Material 3 "Cannot parse the specified color undefined. Please verify it is a hex color"


I have just upgraded an Angular project to latest version as of today (version 18.0.0) including material library using material 3 design. From the documentation here, I am trying to generate a custom theme using the below schematic:

ng generate @angular/material:m3-theme

However I get the bellow error message and I cannot seem to find how to pass the base color as a parameter.

Cannot parse the specified color undefined. Please verify it is a hex color (ex. #ffffff or ffffff).

Have tried different values like --color --c --colour but cannot seem to get it to work and there is no examples on the Angular documentation.

UPDATE

The issue is that the "ng generate @angular/material:m3-theme" command does not work on Windows using Git Bash. Tried the command on normal windows command prompt and it worked fine.


Solution

  • run in your angular project

    ng generate @angular/material:m3-theme
    

    when you show message

    ? What HEX color should be used to generate the M3 theme? It will represent your primary color palette. (ex. #ffffff)
    

    write an hexadecimal color like as

    #F1F2F3
    

    Example if case you don't specify hexadecimal color enter image description here

    Working process enter image description here