How to Change the Font in Your Weaverse Theme
Weaverse themes use modern font loading techniques for performance and flexibility. The default Pilot theme uses fontsource for Google Fonts, but you can use any web font provider or upload custom fonts. This guide covers all approaches with practical examples.1. Using Fontsource (Recommended)
Fontsource provides npm packages for hundreds of Google Fonts and more, including support for variable fonts.a. Install the Fontsource Package
To use a specific font (e.g., Inter or a variable font like Nunito Sans):b. Import Font Files in root.tsx
Reference your code (Pilot theme):c. Update Tailwind’s fontFamily Configuration
To ensure Tailwind’sfont-sans
and related utilities use your new font, update the fontFamily
in your tailwind.config.js
.
Example (Pilot theme):
@font-face
declaration.
d. Update CSS Variables or Classes (if needed)
If you use global CSS instead of Tailwind utilities, set your font in global styles:2. Using Google Fonts CDN
For a quick setup, add a<link>
in your <head>
:
tailwind.config.js
:
CSP Reminder: If you load fonts from an external CDN (such as Google Fonts), make sure to update your Content Security Policy (CSP) to allow the font and stylesheet sources. See the CSP guide for details and examples.
3. Uploading a Custom Font
a. Add Font Files to the Public Folder
Place.woff2
, .woff
, or .ttf
files in public/fonts/
.
b. Declare @font-face in CSS
c. Update Tailwind’s fontFamily
In yourtailwind.config.js
:
4. Switching Fonts Dynamically (Optional)
To let merchants select fonts in Weaverse Studio:- Add a font selector input in your theme schema (see
schema.server.ts
). - Use the selected value to set the font-family dynamically in your global styles or inject it into your Tailwind config.
5. Best Practices
- Only load the weights/styles you use.
- Use
font-display: swap
for performance. - Prefer
.woff2
for custom fonts. - Test on all devices and browsers.
- Respect font licensing for custom fonts.