[examples] Fix material-next-app-router Font Usage with next/font #38026
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR aims to align all the used
font-family
styles of MUI components whennext/font
is used.With the current approach,
className
which containsfont-family
fromnext/font
is added tobody
and thefont-family
fromnext/font
is applied to generic HTML elements.But MUI components still use the default
font-family
fromtheme
and since we don't install Roboto font with CDN etc., they don't use this font and they fall back to next fonts likeHelvetica
.For example, we can check the "On This Page" text. It is a
Typography
component and it uses the default"Roboto", "Helvetiva", "Arial", sans-serif
font-family
even if we set theclassName
ofbody
.But after this change, it will start using
--font-roboto
CSS variable, which we got fromnext/font
and set onhtml
element.And here are the fullpage screenshots.
Before:
After: