Skip to content

bug(Material): theme-overrrides typography not working #31191

@mattiLeBlanc

Description

@mattiLeBlanc

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

I am trying to override my theme variables:

 @include mat.theme-overrides(
    (
      background: #000,
      on-surface: #fff,
      label-large: 600 1.25rem/1.5rem "Inter Tight",
    )
  );

and the label-large does not get changed.
When I look at the generated styles:

--mat-sys-label-large-font: Inter Tight;
    --mat-sys-label-large-line-height: 1.25rem;
    --mat-sys-label-large-size: 0.875rem;
    --mat-sys-label-large-tracking: 0.006rem;
    --mat-sys-label-large-weight: 500;

they dont match my label-large overrides.

I can't provide a map like this either:

@include mat.theme-overrides((
  label-large: (
    font: 'Inter Tight',
    weight: 600,
    size: 1.25rem,
    line-height: 1.5rem,
  ),

Reproduction

I tried creating a stackblitz but the starter is not using SCSS and stackblitz now turned into this new system Bolt. I tried creating an app but it took ages and it broke.

I hope my issue can just b traced by looking at the supported theme-overrides

Looking at the file _m3-tokes.sss
I see

'label-large',
'label-large-font',
'label-large-line-height',
'label-large-size',
'label-large-tracking',
'label-large-weight',
'label-large-weight-prominent',

When I use label-large-size: 1.25, in my override, it works. But the label-large: 600 1.25rem/1.5rem "Inter Tight", doesnt work.

Expected Behavior

apply label-large and other overrides

Actual Behavior

Some default value is used unless I specifically mention each font property separately for the button:

.mat-mdc-unelevated-button {
transition: box-shadow 280ms cubic-bezier(0.4, 0, 0.2, 1);
height: var(--mdc-filled-button-container-height, 40px);
font-family: var(--mdc-filled-button-label-text-font, var(--mat-sys-label-large-font));
font-size: var(--mdc-filled-button-label-text-size, var(--mat-sys-label-large-size)); <=== --mat-sys-label-large-size would be 0.875rem
letter-spacing: var(--mdc-filled-button-label-text-tracking, var(--mat-sys-label-large-tracking));
text-transform: var(--mdc-filled-button-label-text-transform);
font-weight: var(--mdc-filled-button-label-text-weight, var(--mat-sys-label-large-weight));
padding: 0 var(--mat-filled-button-horizontal-padding, 24px);
}

Environment

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

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: theming

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions