MyApp

Getting Started

Introduction

Content & Marketing

Add Blog PostAdd Blog AuthorAdd TestimonialsCustomize HeroAdd FAQ Items

Payments

Add Stripe ProductCreate Stripe SubscriptionAdd Stripe CouponCustomize CheckoutTest Payments Locally

Authentication

Customize Sign-InAdd OAuthImplement RolesProtect Routes

Content Management

Add Doc PageCreate Doc SectionCustomize Theme

Customization

Change ColorsAdd FontCustomize EmailsUse PostHog Analytics

Deployment

Deploy VercelDatabase Migrations

Advanced

Server ActionsAdd Rate Limiting
MyApp

Add Font

Learn how to add custom fonts to your application

Learn how to add custom fonts to your Plainform application.

Goal

By the end of this recipe, you'll have added a custom font to your application.

Prerequisites

  • A working Plainform installation
  • Font files or Google Fonts selection

Steps

Add Google Font

Update app/layout.tsx to import your font:

app/layout.tsx
import { Inter, Poppins } from 'next/font/google';

const inter = Inter({
  subsets: ['latin'],
  variable: '--font-sans',
});

const poppins = Poppins({
  subsets: ['latin'],
  weight: ['400', '500', '600', '700'],
  variable: '--font-heading',
});

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en" className={`${inter.variable} ${poppins.variable}`}>
      <body>{children}</body>
    </html>
  );
}

Update Tailwind Config

Add the font to your Tailwind config:

tailwind.config.ts
export default {
  theme: {
    extend: {
      fontFamily: {
        sans: ['var(--font-sans)'],
        heading: ['var(--font-heading)'],
      },
    },
  },
};

Use the Font

Apply the font in your components:

<h1 className="font-heading text-4xl">
  Your Heading
</h1>

Publish Your Changes

Commit and push:

git add .
git commit -m "style: add custom font"
git push origin main

Using Custom Font Files

For custom font files (not from Google Fonts):

  1. Place font files in public/fonts/
  2. Use next/font/local:
app/layout.tsx
import localFont from 'next/font/local';

const customFont = localFont({
  src: [
    {
      path: '../public/fonts/custom-regular.woff2',
      weight: '400',
      style: 'normal',
    },
    {
      path: '../public/fonts/custom-bold.woff2',
      weight: '700',
      style: 'normal',
    },
  ],
  variable: '--font-custom',
});

Common Issues

Font Not Loading

  • Check font import path is correct
  • Verify font variable is added to <html> className
  • Ensure Tailwind config includes the font family

Font Looks Different

  • Check font weights are imported correctly
  • Verify fallback fonts in Tailwind config

Next Steps

  • Change Colors - Customize color scheme
  • Customize Emails - Brand your emails

Related Documentation

  • Next.js Font Optimization - Font optimization guide
  • Google Fonts - Browse available fonts

How is this guide ?

Last updated on

Change Colors

Learn how to customize your application's color scheme

Customize Emails

Learn how to customize email templates in your application

On this page

Goal
Prerequisites
Steps
Add Google Font
Update Tailwind Config
Use the Font
Publish Your Changes
Using Custom Font Files
Common Issues
Font Not Loading
Font Looks Different
Next Steps
Related Documentation