[typography] global typography variables no longer work as before in V5
See original GitHub issueBug 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:
- Created 4 years ago
- Reactions:4
- Comments:5 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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;If you’re using the individual packages, this is not necessary because they have backwards-compatible import files.
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.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.