Is there a way to add custom font to specific component?
Answered
Yusuf posted this in #help-forum
![Avatar](https://cdn.discordapp.com/avatars/524493936845258766/480628e5e007cf5c160dc18c978bb4f5.webp?size=256)
YusufOP
I have a component that will need to use a bunch of one-off fonts, I don't want to load these fonts on every page, only pages that will use that component, is this possible with next or react?
Answered by DirtyCajunRice | AppDir
iif not, just make a font util file, define them all there, then import the font.className to the div
14 Replies
![Avatar](https://cdn.discordapp.com/avatars/184479429404262410/a_35db4fb943e84d39bb02d6ec0f1d0b7e.gif?size=256)
DirtyCajunRice | AppDir
yep absolutely
are you using tailwind?
![Avatar](https://cdn.discordapp.com/avatars/184479429404262410/a_35db4fb943e84d39bb02d6ec0f1d0b7e.gif?size=256)
DirtyCajunRice | AppDir
iif not, just make a font util file, define them all there, then import the font.className to the div
Answer
![Avatar](https://cdn.discordapp.com/avatars/524493936845258766/480628e5e007cf5c160dc18c978bb4f5.webp?size=256)
YusufOP
I am, I thought it would be harder with tailwindcss because it only has a global config
![Avatar](https://cdn.discordapp.com/avatars/184479429404262410/a_35db4fb943e84d39bb02d6ec0f1d0b7e.gif?size=256)
DirtyCajunRice | AppDir
not necessarily. do you know how to use font variables?
![Avatar](https://cdn.discordapp.com/avatars/524493936845258766/480628e5e007cf5c160dc18c978bb4f5.webp?size=256)
YusufOP
if you mean the next/font library then I have a basic understanding
![Avatar](https://cdn.discordapp.com/avatars/184479429404262410/a_35db4fb943e84d39bb02d6ec0f1d0b7e.gif?size=256)
DirtyCajunRice | AppDir
yeah but more specifically the variable key in the font definition, as well as adding it as a reference in the tailwind config
![Avatar](https://cdn.discordapp.com/avatars/524493936845258766/480628e5e007cf5c160dc18c978bb4f5.webp?size=256)
YusufOP
oh I got you, that's what I do for my regular use fonts
I set a variable name and then use it in the tailwind config
![Avatar](https://cdn.discordapp.com/avatars/184479429404262410/a_35db4fb943e84d39bb02d6ec0f1d0b7e.gif?size=256)
DirtyCajunRice | AppDir
exactly. You can just do that. if its a shit ton of fonts it may be cumbersome tho
![Avatar](https://cdn.discordapp.com/avatars/524493936845258766/480628e5e007cf5c160dc18c978bb4f5.webp?size=256)
YusufOP
and those will be only fetched on the pages that use them?
![Avatar](https://cdn.discordapp.com/avatars/184479429404262410/a_35db4fb943e84d39bb02d6ec0f1d0b7e.gif?size=256)
DirtyCajunRice | AppDir
i believe so. if not, my other suggestion is the only way
![Avatar](https://cdn.discordapp.com/avatars/524493936845258766/480628e5e007cf5c160dc18c978bb4f5.webp?size=256)
YusufOP
thank you for the help!
and I'll do more research about that later