Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task
mattiLeBlanc opened this issue May 22, 2025 · 1 comment
Closed
1 task

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

mattiLeBlanc opened this issue May 22, 2025 · 1 comment
Assignees
Labels
area: theming P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@mattiLeBlanc
Copy link

mattiLeBlanc commented May 22, 2025

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):
@mattiLeBlanc mattiLeBlanc added the needs triage This issue needs to be triaged by the team label May 22, 2025
@crisbeto crisbeto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent area: theming and removed needs triage This issue needs to be triaged by the team labels May 28, 2025
@andrewseguin
Copy link
Contributor

This is working as expected, since the Material components all rely on the individual typography system tokens like label-large-weight, and label-large-size. The overrides can be used to define these typography tokens at a high level.

I agree the ergonomics is not great here. It would have been better I think if we relied on the font shorthand string, making it easier to override and understand.

This is likely a change we'll make either in an upcoming minor or major.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: theming P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

No branches or pull requests

3 participants