Skip to content

Next.js 13 fonts with MUI components #45433

Answered by MatusJurcak
MatusJurcak asked this question in Help
Discussion options

You must be logged in to vote

After a year I found a solution that I'm most happy with. @benwwalker 's solution is great, but works only if you want to use one font in the dialog and also you still cannot use the font variables (somefont.variable) ,as shown in the NextJS docs, because that variable is defined only inside the main element.

My solution was to add the font variables to the MuiModal and MuiMenu elements the same way as I used it inside the main element. So my MUI theme looks something like this:

const mainFont = Barlow({
    weight: ['300'],
    variable: '--font-barlow',
    subsets: ['latin', 'latin-ext'],
});

const headingsFont = Barlow_Condensed({
    weight: ['300'],
    variable: '--font-barlow-con…

Replies: 7 comments 8 replies

Comment options

You must be logged in to vote
6 replies
@nkardjoudj-sobotech
Comment options

@bjackson42
Comment options

@luizguilherme4
Comment options

@slavache
Comment options

@DjayNii
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@zacharymichaelmoore
Comment options

@bastien612
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by MatusJurcak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet