Add custom fonts

Install Google Fonts

Enter one or more family names. Copy the generated command and run it from the project root in VS Code's terminal. It installs self-hosted Fontsource packages and adds the fonts to Typography Builder without changing your default fonts.

Separate names with commas or new lines.

Use your own font files

Self-host a licensed font so the browser can load it directly from your site. This guide does not upload files or change the project's styles.

  1. Put your licensed .woff2 file in public/fonts/. Create the folder if needed.
  2. Add an @font-face rule to src/styles/themes/fonts.css, below the existing imports. Use your actual font name, file name, weight, and style.
    @font-face {
      font-family: "Example Sans";
      src: url("/fonts/example-sans.woff2") format("woff2");
      font-style: normal;
      font-weight: 400;
      font-display: swap;
    }
    Add a separate rule for each additional weight or style, or a supported weight range for a variable font.
  3. Inside the existing @theme static block, add a token such as --font-example-sans: "Example Sans", sans-serif;. You can then use font-example-sans in your markup.
  4. To list the font in Typography Builder, add "var(--font-example-sans)": "Example Sans" to typographyFonts in src/data/typography-builder.js. Reopen Typography Builder and select it under Font family.