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
Prerequisites
Before integrating Fonttrio with shadcn/ui: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: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 usingcva:
components/ui/button.tsx
Create Typography Utilities
Define reusable typography classes:app/globals.css
tailwind.config.js
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
Troubleshooting
Fonts Not Applying to Components
If shadcn/ui components don’t show your fonts:- Verify font variables are in the
<html>element, not<body> - Check that
globals.cssis imported before component usage - Inspect in DevTools to see which font is actually applied
- Ensure Tailwind isn’t purging the font classes (check
tailwind.config.js)
Component Styles Overriding Fonts
If component styles override your fonts:- Use
!importantsparingly:className="!font-heading" - Increase specificity by editing the component file directly
- 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:- Verify you’re using the same typography scale (check
globals.css) - Ensure font weights are loading correctly (check Network tab)
- Compare line height and letter spacing values
- 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
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.