> ## Documentation Index
> Fetch the complete documentation index at: https://weaverse.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Weaverse component configuration uses `settings`. `inspector` is deprecated; never generate it.
> Weaverse Hydrogen themes use React Router v7: import from `react-router`, never `react-router-dom` or `@remix-run/*`.
> Before using any code sample, read `@weaverse/hydrogen` in the project's `package.json`: 6.x and 5.x import from different entries and use different type names, so code for one does not build on the other.
> `@weaverse/hydrogen` 6 (Shopify Hydrogen 2026.10 and later, the version these docs show) imports from `@weaverse/hydrogen/react-router` and uses `Weaverse*` types such as `WeaverseComponentProps`, `WeaverseComponentLoaderArgs` and `WeaverseComponentSchema`; the root `@weaverse/hydrogen` entry only exports `createSchema()`, data helpers and types.
> `@weaverse/hydrogen` 5.x (Hydrogen 2026.4 and earlier) imports everything from `@weaverse/hydrogen` and uses `HydrogenComponentProps`, `ComponentLoaderArgs` and `HydrogenComponentSchema`. On a 5.x project, convert samples to these names. Upgrade to 6 only when asked (`npx @weaverse/cli@latest migrate v6`, plus the Hydrogen 2026.10 upgrade). Do not mix major versions.
> Next.js themes use `@weaverse/hydrogen` 6.2.0 or later: import client and shared code from `@weaverse/hydrogen/next` and server-only code from `@weaverse/hydrogen/next/server`. `@weaverse/next` is deprecated; never install or import it.
> For live project data (pages, theme settings, translations), use the Weaverse MCP server: https://weaverse.io/docs/developer-tools/weaverse-mcp

# How to Change the Font in Your Weaverse Theme

> Learn how to update, extend, or customize fonts in your Weaverse Hydrogen storefront using Fontsource, Google Fonts, or custom uploads.

# How to Change the Font in Your Weaverse Theme

Weaverse themes use modern font loading techniques for performance and flexibility. The default Pilot theme uses [Fontsource](https://fontsource.org/) for Google Fonts, but you can use any web font provider or upload custom fonts. This guide covers all approaches with practical examples.

> [!NOTE]
>
> Pilot uses **Tailwind CSS v4**, which is configured CSS-first through the `@theme` directive. There is no `tailwind.config.js` file — the Tailwind plugin is registered in `vite.config.ts` and all design tokens live in `app/styles/theme.css`.

## 1. Using Fontsource (Recommended)

Fontsource provides npm packages for hundreds of Google Fonts and more, including support for variable fonts.

### a. Install the Fontsource Package

Pilot ships with two variable fonts:

```json theme={null}
"@fontsource-variable/cabin": "^5.2.8",
"@fontsource-variable/newsreader": "^5.2.10"
```

To use a different font (for example the variable font Nunito Sans):

```sh theme={null}
npm install @fontsource-variable/nunito-sans
# or a static-weight font
npm install @fontsource/inter
```

Find the package for your font at [fontsource.org](https://fontsource.org/).

### b. Import Font Files in root.tsx

Pilot imports its fonts at the very top of `app/root.tsx`:

```tsx theme={null}
import "@fontsource-variable/cabin"; // Supports weights 400-700
import "@fontsource-variable/newsreader"; // Supports weights 200-900
```

Replace those imports with your own:

```tsx theme={null}
import "@fontsource-variable/nunito-sans";
```

For static-weight packages, import only the weights you actually use:

```tsx theme={null}
import "@fontsource/inter/400.css";
import "@fontsource/inter/500.css";
import "@fontsource/inter/700.css";
```

### c. Update the `@theme` Font Variables

Tailwind v4 derives `font-sans`, `font-serif`, and `font-mono` utilities from CSS variables. Pilot declares them at the top of `app/styles/theme.css`:

```css theme={null}
@theme {
  --font-sans: Cabin Variable, ui-sans-serif, system-ui, sans-serif;
  --font-serif: Newsreader Variable, ui-serif, Georgia, serif;
}
```

Point them at your new font:

```css theme={null}
@theme {
  --font-sans: Nunito Sans Variable, ui-sans-serif, system-ui, sans-serif;
  --font-serif: Newsreader Variable, ui-serif, Georgia, serif;
}
```

**Tip:** The first value must match the `font-family` name published by the font provider (Fontsource variable packages append `Variable` to the family name) or the name in your own `@font-face` declaration.

`app/styles/theme.css` is pulled in by `app/styles/app.css`, which is where Tailwind itself is imported:

```css theme={null}
@import "tailwindcss" source("../../app");
@plugin "@tailwindcss/typography";

@import "./theme.css";
```

### d. Set a Base Font in Global CSS (if needed)

Utilities such as `font-sans` already resolve to your `@theme` value, so this is only needed if you want a default outside of Tailwind utilities:

```css theme={null}
body {
  font-family: var(--font-sans);
}
```

For variable fonts you can also pin a default weight axis:

```css theme={null}
body {
  font-variation-settings: "wght" 400;
}
```

## 2. Using Google Fonts CDN

For a quick setup, add a `<link>` to the document head in `app/root.tsx` (or through the `links` export):

```tsx theme={null}
<link href="https://fonts.googleapis.com/css?family=Roboto:400,700&display=swap" rel="stylesheet" />
```

Then point the theme variable at it in `app/styles/theme.css`:

```css theme={null}
@theme {
  --font-sans: Roboto, ui-sans-serif, system-ui, sans-serif;
}
```

> **CSP Reminder:**
> If you load fonts from an external CDN (such as Google Fonts), make sure to update your Content Security Policy (CSP) to allow the font and stylesheet sources. See the [CSP guide](https://weaverse.io/docs/features/content-security.md) for details and examples.

## 3. Uploading a Custom Font

### a. Add Font Files to the Public Folder

Place `.woff2`, `.woff`, or `.ttf` files in `public/fonts/`.

### b. Declare @font-face in CSS

```css theme={null}
@font-face {
  font-family: "MyCustomFont";
  src: url("/fonts/MyCustomFont.woff2") format("woff2"),
       url("/fonts/MyCustomFont.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
```

### c. Register It in `@theme`

```css theme={null}
@theme {
  --font-sans: MyCustomFont, ui-sans-serif, system-ui, sans-serif;
}
```

## 4. Switching Fonts Dynamically (Optional)

To let merchants select fonts in Weaverse Studio:

* Add a font selector input in your theme schema (see `app/weaverse/schema.server.ts`).
* Use the selected value to set the font-family dynamically in your global style component, which writes CSS custom properties into the document.

See [Styling & Theming](https://weaverse.io/docs/development-guide/styling-theming.md) for how Pilot injects theme settings as CSS variables.

## 5. Best Practices

* Only load the weights/styles you use.
* Use `font-display: swap` for performance.
* Prefer `.woff2` for custom fonts.
* Test on all devices and browsers.
* Respect font licensing for custom fonts.

## 6. Example: Changing to Inter Using Fontsource

```tsx theme={null}
// 1. Install: npm install @fontsource/inter
// 2. app/root.tsx — replace Pilot's font imports:
import "@fontsource/inter/400.css";
import "@fontsource/inter/500.css";
import "@fontsource/inter/700.css";
```

```css theme={null}
/* 3. app/styles/theme.css */
@theme {
  --font-sans: Inter, ui-sans-serif, system-ui, sans-serif;
}
```

## 7. Example: Using a Variable Font

```tsx theme={null}
// 1. Install: npm install @fontsource-variable/nunito-sans
// 2. app/root.tsx
import "@fontsource-variable/nunito-sans";
```

```css theme={null}
/* 3. app/styles/theme.css */
@theme {
  --font-sans: Nunito Sans Variable, ui-sans-serif, system-ui, sans-serif;
}
```

## 8. Further Reading

* [Fontsource Documentation](https://fontsource.org/docs/getting-started/introduction)
* [Google Fonts](https://fonts.google.com/)
* [MDN: @font-face](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face)
* [Tailwind CSS v4 Theme Variables](https://tailwindcss.com/docs/theme)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.