Skip to main content

Installation

This guide covers everything you need to know about installing and setting up Fonttrio in your project.

Requirements

Before installing Fonttrio, ensure your project meets these requirements:

Next.js 14+

App Router required for next/font support

shadcn/ui

CLI must be installed and configured

Tailwind CSS

Required for utility classes
Fonttrio uses the shadcn/ui registry system, which requires the shadcn CLI to be installed in your project.

Prerequisites Setup

If you’re starting a new project, follow these steps:
1

Create a Next.js project

Create a new Next.js 14+ project with the App Router:
When prompted, select:
  • ✅ TypeScript
  • ✅ Tailwind CSS
  • ✅ App Router
2

Initialize shadcn/ui

Install and configure shadcn/ui in your project:
This will:
  • Install required dependencies
  • Create components.json configuration
  • Set up your components/ui directory
  • Configure your tailwind.config and globals.css
3

Verify setup

Ensure your project has these files:
  • app/layout.tsx - App Router layout
  • app/globals.css - Global styles
  • components.json - shadcn configuration
  • tailwind.config.ts - Tailwind configuration

Installing a Font Pairing

1

Browse available pairings

Visit fonttrio.xyz to browse all 49 curated pairings. Each pairing page includes:
  • Live preview with actual fonts
  • Typography scale visualization
  • Interactive type tester
  • Context previews (blog, landing, docs)
  • One-click copy install command
2

Copy the install command

Each pairing has a unique registry URL. The install command follows this pattern:
For example, to install the Editorial pairing:
3

What gets installed

The shadcn CLI will:
  1. Download font configurations from the Fonttrio registry
  2. Install three fonts (heading, body, mono) via next/font/google
  3. Add CSS variables to your app/globals.css:
  4. Apply typography scale with optimized sizing:
  5. Configure font loading in your root layout
4

Verify installation

Check your app/globals.css file. You should see:
  • Font variable declarations in :root
  • Typography scale styles for h1-h6
  • Body and code font assignments
Example output for the Editorial pairing:

Registry Structure

Each pairing is distributed as a JSON registry item:

Using Fonts in Your App

After installation, fonts are available throughout your project:

Automatic HTML Element Styling

The typography scale automatically styles HTML elements:

Using CSS Variables Directly

For custom components, use the CSS variables with Tailwind:

In Tailwind Config

You can also extend your Tailwind config to create utility classes:
Then use them as Tailwind classes:

Installing Multiple Pairings

You can install multiple pairings in the same project:
All fonts will be loaded, and you can switch between pairings by updating the CSS variables:

Customizing Typography Scale

You can customize the typography scale by editing globals.css:

Troubleshooting

Symptom: Fonts don’t appear after installation.Solutions:
  1. Clear your browser cache and hard refresh (Cmd/Ctrl + Shift + R)
  2. Restart your Next.js dev server
  3. Check that CSS variables are present in globals.css
  4. Verify next/font is working:
  5. Check browser console for font loading errors
Symptom: Console shows “CSS variable not found” errors.Solutions:
  1. Verify the pairing was installed:
  2. Ensure globals.css is imported in your root layout:
  3. Check CSS variable syntax - should use var(--font-heading) not --font-heading
Symptom: HTML elements don’t have the expected styling.Solutions:
  1. Check CSS specificity - your custom styles may be overriding Fonttrio
  2. Ensure no other CSS is resetting h1-h6 styles
  3. Verify the typography scale CSS is present after the variables in globals.css
  4. Try using !important temporarily to diagnose specificity issues
Symptom: shadcn add command fails.Solutions:
  1. Verify shadcn is initialized:
  2. Update to latest shadcn version:
  3. Check internet connection - registry must be reachable
  4. Try with full URL including .json extension
Symptom: Fonts appear too bold or too light.Solutions:
  1. Check which font weights are loaded in the registry JSON
  2. Google Fonts may not include all weights for every font
  3. Customize weight in your CSS:
  4. Some fonts have optical size variants - check if that’s enabled
Symptom: Slow page loads or layout shift.Solutions:
  1. Fonttrio uses next/font which includes automatic optimization
  2. Fonts are loaded from Google Fonts CDN with optimal caching
  3. Reduce number of font weights if performance is critical
  4. Use font-display: swap (default in next/font)
  5. Consider font subsetting for non-Latin characters

Best Practices

Font Loading

  • Let next/font handle optimization
  • Don’t manually load Google Fonts
  • Keep font weights minimal (2-3 max)
  • Use variable fonts when available

CSS Variables

  • Use the provided variables consistently
  • Don’t hardcode font family names
  • Extend in Tailwind config for convenience
  • Document any customizations

Typography Scale

  • Maintain consistent scale ratios
  • Test at different viewport sizes
  • Use relative units (rem) for accessibility
  • Keep line heights readable (1.5-1.65 for body)

Customization

  • Start with defaults, then customize
  • Test changes across all components
  • Document your scale in design system
  • Consider dark mode contrast

Next Steps

Quickstart

Get started in under 2 minutes

Browse Pairings

Explore all 49 curated pairings

Examples

See real-world usage examples
License Note: All fonts distributed through Fonttrio are from Google Fonts and are open source. Check individual font licenses for commercial use terms.