Skip to content

bug(Theming): When creating a theme using mat.theme( there is no way to configure typography like how we have with mat.define-theme #30444

Closed
@kai1992cool

Description

@kai1992cool

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

No response

Description

When applying a theme like below:

@use '@angular/material' as mat;

body {
  // font-family: Roboto, 'Helvetica Neue', sans-serif;

  @include mat.theme(
    (
      color: (
        theme-type: light,
        primary: mat.$spring-green-palette,
      ),
      typography: Roboto,
      density: 0,
    )
  );
}

html {
  height: 100%;
}

Without the commented code in body tag, the h1 to h6 tags do not have the default font-family.

Stackblitz mat.theme


In the old method we had the typography-hierarchy, set this up and it works great:

@use '@angular/material' as mat;

$theme: mat.define-theme(
  (
    color: (
      theme-type: light,
      primary: mat.$spring-green-palette,
    ),
    typography: (
      plain-family: Roboto,
      brand-family: Open Sans,
      bold-weight: 900,
      medium-weight: 500,
      regular-weight: 300,
    ),
    density: (
      scale: 0,
    ),
  )
);
body {
  @include mat.core();
  @include mat.all-component-themes($theme);
}

@include mat.typography-hierarchy($theme);

html {
  height: 100%;
}

Stackblitz Demo

So the question is how to define the typography for h1-h6 with mat.theme(

Reproduction

StackBlitz link:
Steps to reproduce:
1.
2.

Expected Behavior

way to configure typography with define-theme

Actual Behavior

no way to configure typography with define-theme

Environment

  • Angular: 19
  • CDK/Material:19
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows

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