question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[typography] global typography variables no longer work as before in V5

See original GitHub issue

Bug report

Steps to reproduce

When setting global typography variables I used to be able to do the following and it worked.

$mdc-typography-font-family: 'Gotham SSm A', 'Gotham SSm B', arial, sans-serif;
$mdc-typography-styles-button: ( font-size: 0.95rem );
$mdc-typography-styles-body1: (font-size: 1rem ); 
$mdc-typography-styles-headline6: (font-size: 1.1rem); 

@import '~material-components-web/material-components-web';

However in version 5 the above does not work

I tried to use something like the following but the styles do not get updated

$mdc-typography-font-family: 'Gotham SSm A', 'Gotham SSm B', arial, sans-serif;
$mdc-typography-styles-button: ( font-size: 0.95rem );
$mdc-typography-styles-body1: (font-size: 1rem ); 
$mdc-typography-styles-headline6: (font-size: 1.1rem); 

@use '@material/typography' ; //or @use material-components..

I was able to make the font-family work by using the following

$gotham-font-family: unquote("'Gotham SSm A', 'Gotham SSm B', arial, sans-serif");

@use '@material/typography' with (
    $font-family: $gotham-font-family,

);

I do not know how to set the styles using this method however.

Actual behavior

styles are not getting set in the material components

Expected behavior

styles should be set for material components

Screenshots

Your Environment:

Software Version(s)
MDC Web 5
Browser
Operating System

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
asyncLizcommented, Feb 21, 2020

So a couple of discoveries. The material-components-web combined package uses the module system exclusively. If you’re using it, you will need to use the module system to define the font family variable;

@use '@material/typography' with (
  $font-family: Arial
);

@import 'material-components-web/material-components-web';

If you’re using the individual packages, this is not necessary because they have backwards-compatible import files.

$mdc-typography-font-family: Arial;

@import '@material/typography/mdc-typography';

I would personally recommend using npm i material-components-web as a handy way to install everything, but then import individual packages that you use. That way you’re not generating extra CSS.

The $mdc-typography-styles-<STYLE> global variables are not working. I’ll keep investigating why and how we could fix it.

0reactions
asyncLizcommented, Feb 24, 2020

Fixed in #5643. The Override Styles section of the readme now includes how you can customize with global variables, sass module variables, or CSS custom properties.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Typography · Bootstrap v5.1
Bootstrap sets basic global display, typography, and link styles. When more control is needed, check out the textual utility classes.
Read more >
html - How can I change the Bootstrap default font family using ...
The idea is to override Bootstraps Sass variable for font family in your custom Sass file. If you are using Google Fonts, then...
Read more >
Variable Fonts: What web authors need to know
There are more and more people writing about variable fonts, what they are, and how to use them—which is amazing.
Read more >
Get Started with Font Awesome
Font Awesome CDN is the easiest way to get Font Awesome on your website or app, all with just a single line of...
Read more >
Typography - Material UI - MUI
⚠️ This requires that you have a plugin or loader in your build process that can handle loading ttf , woff , and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found