ui: fontFamily is not applied in tailwind.config.js file
When I comment out the code below from tailwindcss.config.cjs file, I get sans-fonts displayed. Otherwise I get serif-fonts with the sans key somehow. How to get proper fonts?
fontFamily: {
sans: ['var(--font-sans)', ...fontFamily.sans],
},
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 11
- Comments: 15
Just for anyone who does not like to read @pmabres solution (a) looks like this:
from
to
Worked for me thanks!
So if you are following the manual install guide @lightbluepoppy you’ll find this issue as the css variable is not defined anywhere when doing a manual install ‘var(–font-sans)’ so resolving that fails and it falls back to a serif font. You can either define that css variable in the same css file you’ve defined the rest of the variables or you can just remove the variable usage and just use …fontFamily.sans
Docs should be updated, this got me too - https://ui.shadcn.com/docs/installation/manual
the following worked for me after adding the import statement in tailwind.config.js
It looks like the manual documentation guide suggests an undefined fontFamily. Removing fontFamily altogether solves the issue.
Try removing “var(–font-sans)”, worked for me 😃
@shadcn : I followed the manual instruction and face the same issue. https://ui.shadcn.com/docs/installation/manual
for me issue was that in root layout i was passing font.className but need to be font.variable
Guys. have you been able to resolve the issue? I am getting same issue on my side.
@lightbluepoppy I’m not using the
approuter so I had to do some other things that solved my dropdown menu typography issue. I needed to update the_app.tsxand the_document.tsx.In the
_document.tsxI had to add thisand in the
_app.tsxI added a html wrapper and added the font-sans there as wellI thought it was weird it needed to be added in both places. Not sure how relevant that is for your use case but maybe that will trigger some ideas. Good luck!
@bluengreen This looks correct.