After upgrading my Angular core libraries to version 18, I migrated to Angular Material 18 by running:
ng update @angular/material
The update went smoothly but when I tried to compile my app I got the following error:
X [ERROR] Undefined function.
╷
14 │ $myapp-theme-primary: mat.define-palette(mat.$indigo-palette, A400, A100, A700);
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
╵
src\styles.scss 14:23 root stylesheet [plugin angular-sass]
angular:styles/global:styles:2:8:
2 │ @import 'src/styles.scss';
╵ ~~~~~~~~~~~~~~~~~
My styles.scss
worked perfectly with the previous version of Angular Material (v.17). It looks as follows:
@use '@angular/material' as mat;
@include mat.core();
$myapp-theme-primary: mat.define-palette(mat.$indigo-palette, A400, A100, A700);
$myapp-theme-accent: mat.define-palette(mat.$indigo-palette);
$myapp-theme-warn: mat.define-palette(mat.$red-palette);
$myapp-theme: mat.define-light-theme((
color: (
primary: $myapp-theme-primary,
accent: $myapp-theme-accent,
warn: $myapp-theme-warn,
)
));
@include mat.all-component-themes($myapp-theme);
How do I have to adapt my code in styles.scss
in order to make it work with Angular Material 18?