Why Mix Pairings?
Installing multiple pairings is useful for:- A/B testing different typography styles before committing
- Multi-section apps where different areas need different moods (e.g., marketing landing page + documentation + app dashboard)
- Theme switching to let users choose their preferred reading experience
- Custom combinations by mixing fonts from different pairings
Installing Multiple Pairings
You can install as many pairings as you want. Each pairing adds its fonts to theregistry/ directory:
1
Install First Pairing
Start with your primary pairing.This installs:
registry/fonts/playfair-display.tsxregistry/fonts/source-serif-4.tsxregistry/fonts/jetbrains-mono.tsxregistry/pairings/editorial.tsx
2
Install Second Pairing
Add another pairing for comparison or mixing.This adds:
registry/fonts/inter.tsx(new)registry/fonts/jetbrains-mono.tsx(skipped, already exists)registry/pairings/minimal.tsx(new)
3
Install Additional Pairings
Keep adding pairings as needed.
Shared fonts (like JetBrains Mono, which appears in many pairings) are only installed once. Subsequent pairings will reuse the existing font file.
Switching Between Pairings
Once you have multiple pairings installed, you can switch between them in your layout:Method 1: Direct Import Swap
The simplest way is to change which pairing you import:app/layout.tsx
- Comment out the current import
- Uncomment the desired pairing import
- Update the className to use the new pairing’s variables
Method 2: Environment-Based Selection
Use environment variables to select pairings:app/layout.tsx
.env.local:
.env.local
Method 3: User-Selectable Themes
Allow users to switch fonts dynamically:app/providers.tsx
app/layout.tsx
components/font-switcher.tsx
Using Different Pairings in Different Sections
You can apply different pairings to different parts of your app:Method 1: Section-Specific Classes
Import all pairings and apply their variables to specific sections:app/layout.tsx
app/globals.css
Method 2: Route-Based Pairings
Apply different pairings to different route groups:app/(blog)/layout.tsx
app/(dashboard)/layout.tsx
Creating Custom Combinations
Mix and match individual fonts from different pairings:1
Install Source Pairings
Install pairings that contain the fonts you want.
2
Import Individual Fonts
Import only the fonts you need.
app/layout.tsx
3
Apply Custom Combination
Create your own pairing object.
app/layout.tsx
4
Override CSS Variables
Point the variables to your chosen fonts.
app/globals.css
When mixing fonts, ensure they work well together. Consider contrast (serif vs sans), weight compatibility, and x-height. Test thoroughly with real content.
Common Use Cases
Marketing Site + Documentation
Use a bold pairing for the landing page and a readable pairing for docs:Multi-Brand Application
Different brands within the same app:A/B Testing Fonts
Randomly assign pairings for testing:Seasonal Themes
Switch pairings based on time of year:Managing Multiple Pairings
Keep Track of Installed Pairings
Maintain a list of your active pairings:lib/pairings.ts
Load Fonts on Demand
For performance, only load fonts when needed:Update Typography Scale per Pairing
Each pairing may need different CSS adjustments:app/globals.css
Best Practices
1
Limit the Number of Pairings
Don’t install too many pairings. 2-4 is usually enough. Each pairing adds to your bundle size.
2
Maintain Consistency
If using multiple pairings, ensure they’re used consistently across similar contexts. Don’t randomly switch fonts.
3
Test Performance
Monitor page load times when adding multiple pairings. Each font adds HTTP requests and increases bundle size.
4
Document Your Choices
Comment your code to explain why you’re using specific pairings in specific contexts.
5
Consider Users
If allowing users to switch fonts, persist their choice in localStorage and respect their preference across sessions.
Performance Considerations
Font Loading Impact
Each pairing typically includes 3 fonts. If you install 3 pairings, you could have up to 9 fonts (though duplicates are shared).Optimize Font Loading
Usenext/font optimizations:
Subset Fonts
Only load required character sets:Troubleshooting
Fonts Not Switching
If changing pairings doesn’t update fonts:- Verify font variables are applied to the correct element (usually
<html>) - Check that CSS variables in
globals.csspoint to the right fonts - Clear browser cache and reload
- Restart your dev server
CSS Variables Conflicting
If multiple pairings conflict:- Use scoped classes instead of global
:rootvariables - Ensure each section has unique class names
- Check specificity in DevTools to see which styles are winning
Performance Issues
If page load is slow with multiple pairings:- Reduce the number of installed pairings
- Only load fonts needed for the current page
- Use font subsetting to reduce file sizes
- Consider using a variable font instead of multiple weights
Next Steps
Customize Typography
Adjust typography scales for each pairing.
Use with shadcn/ui
Apply mixed pairings to shadcn/ui components.