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.
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.
- Put your licensed
.woff2file inpublic/fonts/. Create the folder if needed. - Add an
@font-facerule tosrc/styles/themes/fonts.css, below the existing imports. Use your actual font name, file name, weight, and style.
Add a separate rule for each additional weight or style, or a supported weight range for a variable font.@font-face { font-family: "Example Sans"; src: url("/fonts/example-sans.woff2") format("woff2"); font-style: normal; font-weight: 400; font-display: swap; } - Inside the existing
@theme staticblock, add a token such as--font-example-sans: "Example Sans", sans-serif;. You can then usefont-example-sansin your markup. - To list the font in Typography Builder, add
"var(--font-example-sans)": "Example Sans"totypographyFontsinsrc/data/typography-builder.js. Reopen Typography Builder and select it under Font family.