Skip to content

Custom fonts

How fonts are wired

Primitives never name a font. They read two CSS variables set on the document root:

--font-display

Used for display elements (brand logos, headings, titles).

--font-body

Used for body, paragraph copy, list texts, buttons, and form inputs.

Declare in a stylesheet

In your consumer application's root stylesheet (e.g., global.css), you can load local fonts or fallback declarations:

/* global.css */
:root {
  --font-display: 'Cinzel', serif;
  --font-body: 'Mulish', sans-serif;
}

Pass to ThemeProvider

If you are using the theme configuration manager, you can feed custom font names directly to the ThemeProvider element. The provider will automatically inject Google Font dependencies and resolve them on the document:

import { ThemeProvider } from "@shavin/ui";

export default function App({ children }) {
  return (
    <ThemeProvider 
      brandColor="grass" 
      radius="medium" 
      displayFont="Fraunces" 
      bodyFont="Outfit"
    >
      {children}
    </ThemeProvider>
  );
}

Use next/font in Next.js

For Next.js projects, use the standard next/font utility to optimize layout shift, mapping the output CSS variable names directly:

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

const displayFont = Fraunces({
  subsets: ['latin'],
  variable: '--font-display',
});

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

export default function RootLayout({ children }) {
  return (
    <html lang="en" className={`${displayFont.variable} ${bodyFont.variable}`}>
      <body>{children}</body>
    </html>
  );
}
Configure Theme
Theme
Brand Color
Custom
Gray Family
Appearance
Radius
Scaling
Panel Style
Heading Font
Body Font