Skip to main content
Fonttrio allows you to install multiple pairings in the same project, making it easy to switch between different font combinations or use different pairings for different sections of your application.

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 the registry/ directory:
1

Install First Pairing

Start with your primary pairing.
This installs:
  • registry/fonts/playfair-display.tsx
  • registry/fonts/source-serif-4.tsx
  • registry/fonts/jetbrains-mono.tsx
  • registry/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
To switch pairings:
  1. Comment out the current import
  2. Uncomment the desired pairing import
  3. Update the className to use the new pairing’s variables

Method 2: Environment-Based Selection

Use environment variables to select pairings:
app/layout.tsx
Set in .env.local:
.env.local

Method 3: User-Selectable Themes

Allow users to switch fonts dynamically:
app/providers.tsx
Use in layout:
app/layout.tsx
Create a font switcher component:
components/font-switcher.tsx
User-selectable fonts can cause a flash of unstyled content (FOUC) during hydration. Consider storing the preference in localStorage and applying it before the initial render.

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
Create section-specific CSS:
app/globals.css
Apply to sections:

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:
Dynamic font loading can cause layout shifts. This approach is only recommended for user-selectable fonts, not for initial page load.

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

Use next/font optimizations:

Subset Fonts

Only load required character sets:

Troubleshooting

Fonts Not Switching

If changing pairings doesn’t update fonts:
  1. Verify font variables are applied to the correct element (usually <html>)
  2. Check that CSS variables in globals.css point to the right fonts
  3. Clear browser cache and reload
  4. Restart your dev server

CSS Variables Conflicting

If multiple pairings conflict:
  1. Use scoped classes instead of global :root variables
  2. Ensure each section has unique class names
  3. Check specificity in DevTools to see which styles are winning

Performance Issues

If page load is slow with multiple pairings:
  1. Reduce the number of installed pairings
  2. Only load fonts needed for the current page
  3. Use font subsetting to reduce file sizes
  4. 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.