Angular Material 17 - How to get primary color from theme in Style.scss

Discussão em 'Angular' iniciado por Bhavesh, Novembro 29, 2024.

  1. Bhavesh

    Bhavesh Guest

    I have just upgraded angular app from 16 to 17. Application has custom theme as below.

    custTheme.scss

    @use '@angular/material' as mat;

    @include mat.core();

    $pp: mat.define-palette(mat.$indigo-palette);
    $primary: mat.get-color-from-palette($pp);
    $ap: mat.define-palette(mat.$pink-palette);
    $accent: mat.get-color-from-palette($ap);
    $wp: mat.define-palette(mat.$red-palette);
    $warn: mat.get-color-from-palette($wp);

    $theme: mat.define-light-theme((
    color: (
    primary: $pp,
    accent: $ap,
    warn: $wp,
    ),
    typography: mat.define-typography-config(),
    ));

    @include mat.all-component-themes($theme);


    this seem to be working fine except when I try to get primary color in Style.scss, it doesn't work

    style.scss

    import '/custTheme';
    background-color: mat-color($primary, darker);


    It doesn't seem to recognise mat-color function. what I get in browser is

    color: mat-color(#616161, darker);


    Can someone please explain what's happening here?

    Thanks

    Continue reading...

Compartilhe esta Página