Angular Material M3 custom theme specific color

Discussão em 'Angular' iniciado por Miklós Szabó, Março 3, 2025.

  1. I'm implementing custom Angular Material M3 theme like described below. My question is if anybody could help me: How can I use a specific item from e.g. the primary color map (for example 30) as a primary color? Couldn't find a description for it. I'm trying to follow the original documentation: https://v18.material.angular.io/guide/theming

    E.g.

    $_primary: map.merge(map.get($_palettes, primary, 30 ???), $_rest);


    My code:

    $_palettes: (
    primary: (
    0: #000000,
    10: #211b00,
    20: #393000,
    25: #453b00,
    ...
    ),
    secondary: (
    0: #000000,
    10: #1b1c1c,
    20: #303030,
    25: #3c3b3b,
    ...
    tertiary: (
    0: #000000,
    10: #112000,
    20: #203600,
    ...
    )
    $_rest: (
    secondary: map.get($_palettes, secondary),
    neutral: map.get($_palettes, neutral),
    neutral-variant: map.get($_palettes, neutral-variant),
    error: map.get($_palettes, error),
    );
    $_primary: map.merge(map.get($_palettes, primary), $_rest);
    $_tertiary: map.merge(map.get($_palettes, tertiary), $_rest);

    $light-theme: mat.define-theme((
    color: (
    theme-type: light,
    primary: $_primary,
    tertiary: $_tertiary,
    )
    ));

    Continue reading...

Compartilhe esta Página