Skip to main content
Fonttrio is designed specifically for shadcn/ui projects. This guide shows you how to apply font pairings to shadcn/ui components, customize component typography, and follow best practices for a cohesive design system.

Why Fonttrio Works with shadcn/ui

Fonttrio uses the same distribution system as shadcn/ui:
  • Registry-based installation via the shadcn CLI
  • Next.js + Tailwind as the foundation
  • CSS variables for theming and customization
  • Copy-paste components that you fully own and can modify
Because both use CSS variables, fonts integrate seamlessly with shadcn/ui’s theming system.

Prerequisites

Before integrating Fonttrio with shadcn/ui:
1

Install shadcn/ui

Set up shadcn/ui in your Next.js project.
2

Install a Fonttrio Pairing

Add your chosen font pairing.
3

Apply Fonts to Layout

Add font variables to your root layout.
app/layout.tsx

Applying Fonts to Components

Once fonts are installed, they automatically apply to shadcn/ui components through CSS variables.

Typography Components

Heading and text components inherit fonts from the typography scale:

Button Components

Buttons use body font by default:
Override with heading font for emphasis:

Form Components

Input fields, labels, and form elements use body font:

Code Components

Code blocks and inline code use monospace font:
If you’ve installed a Fonttrio pairing, the global CSS already applies --font-mono to <code> and <pre> elements, so you don’t need to add classes manually.

Customizing Component Typography

You can customize how fonts apply to specific components.

Modify Component Files

Since shadcn/ui components are copied into your project, you can edit them directly:
components/ui/card.tsx

Create Font-Aware Variants

Add font variants to component APIs using cva:
components/ui/button.tsx
Use in components:

Create Typography Utilities

Define reusable typography classes:
app/globals.css
Or extend Tailwind config:
tailwind.config.js
Use in components:

Component-Specific Examples

Accordion

Tabs

Dialog

Badge

Select

Dark Mode Considerations

Fonttrio pairings work seamlessly with shadcn/ui’s dark mode:

Adjusting Font Weight for Dark Mode

Some fonts may need lighter weights in dark mode:
app/globals.css

Best Practices

1. Maintain Consistency

Use the same fonts for similar UI elements:

2. Respect Component Semantics

Use heading fonts for titles, body fonts for content:

3. Test with Real Content

Test components with actual text, not placeholder content:

4. Consider Font Fallbacks

Ensure graceful degradation:

5. Use Monospace Appropriately

Reserve monospace fonts for code and technical content:

Building a Design System

Create a comprehensive design system with Fonttrio + shadcn/ui:

Define Typography Tokens

lib/design-tokens.ts

Create Reusable Typography Components

components/typography/heading.tsx
components/typography/text.tsx
Use in components:

Troubleshooting

Fonts Not Applying to Components

If shadcn/ui components don’t show your fonts:
  1. Verify font variables are in the <html> element, not <body>
  2. Check that globals.css is imported before component usage
  3. Inspect in DevTools to see which font is actually applied
  4. Ensure Tailwind isn’t purging the font classes (check tailwind.config.js)

Component Styles Overriding Fonts

If component styles override your fonts:
  1. Use !important sparingly: className="!font-heading"
  2. Increase specificity by editing the component file directly
  3. Check the component’s default className prop for conflicting font settings

Fonts Look Different Than Preview Site

If your implementation doesn’t match the Fonttrio preview:
  1. Verify you’re using the same typography scale (check globals.css)
  2. Ensure font weights are loading correctly (check Network tab)
  3. Compare line height and letter spacing values
  4. Check that you’re not overriding font settings with Tailwind classes

Example: Complete Component Integration

Here’s a full example of a Card component with proper typography:
components/feature-card.tsx
Usage:

Next Steps

Browse Pairings

Explore all 49 curated font pairings with live previews.

Customize Typography

Fine-tune font sizes, weights, and spacing for your design.