Problem with next/font/google CSS Variables in Tailwind CSS with Next.js v5 + Tailwind v4 #77337
Unanswered
Jafar-Sabaouni
asked this question in
Help
Replies: 1 comment
-
Referencing variables needs to be inside a @theme inline {
--font-sans: var(--font-inter);
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
I'm currently using Next.js v5 with Tailwind CSS v4 in my project and ran into an issue when trying to integrate fonts from
next/font/google
with my Tailwind configuration.In previous versions of Tailwind, I could assign CSS variables to fonts within the Tailwind theme, and everything worked as expected. However, with the new CSS-based configuration in Tailwind v4, that method no longer seems to function correctly.
My First Attempt (Unsuccessful)
I initially followed the same approach that worked in earlier versions:
layout.tsx
tailwind.config.css
Unfortunately, this setup didn’t work as expected.
What Worked for Me
After some experimentation, I found the simplest solution was to directly assign the font names as strings instead of referencing the CSS variables:
This resolved the issue for me. If anyone has a better or more consistent method of integrating
next/font/google
with Tailwind v4’s new config system, I’d love to hear about it!Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions