Fonts
The preset fonts, self-hosted from Fontsource, and how to change a font.
Astronomic UI uses two fonts: a display font for large headings and a body font for everything else. Two tokens name them, --ui-font-display and --ui-font-body.
The kit's presets use fonts from Fontsource, served by your own site. No preset font comes from Google Fonts or another font host, so a reader's browser never contacts a third party for one.
What Fontsource is
Fontsource puts open-source fonts on npm, one package per font. You install the package, import its CSS file, and your build bundles the font files with your site.
The six presets use Fontsource's variable packages, named @fontsource-variable/<font>. One variable file covers every weight. Create also offers a few static fonts (@fontsource/<font>, one file per weight), and a theme may bundle its own font files instead of a package. A browser downloads a font file only when the page uses that font.
The preset fonts
| Preset | Display font | Body font | Import |
|---|---|---|---|
| Minimal | Geist | Geist | @fontsource-variable/geist/wght.css |
| Clean | Inter | Inter | @fontsource-variable/inter/opsz.css |
| Modern | Plus Jakarta Sans | Plus Jakarta Sans | @fontsource-variable/plus-jakarta-sans/wght.css |
| Playful | Bricolage Grotesque | Nunito | @fontsource-variable/bricolage-grotesque/standard.css and @fontsource-variable/nunito/wght.css |
| Soft | Figtree | Figtree | @fontsource-variable/figtree/wght.css |
| Ink | Newsreader | Libre Franklin | @fontsource-variable/newsreader/opsz.css and @fontsource-variable/libre-franklin/wght.css |
A preset names its fonts but does not load them. Your site loads the fonts its preset uses.
Load a preset's fonts
First, install the font's package. Soft uses Figtree:
pnpm add @fontsource-variable/figtreeThen import its CSS file once, in the layout every page uses:
---
import "@fontsource-variable/figtree/wght.css";
---Last, put the body font on the page's root element, for example <body class="font-body">. Parts set their own display font.
Why each font is named twice
Every variable font stack in the presets names the family twice:
--ui-font-body: "Figtree", "Figtree Variable", ui-sans-serif, system-ui, sans-serif;Fontsource's variable packages name the family "Figtree Variable". Other sources name it "Figtree". With both names, the font works from either source. The system fonts at the end show while the font loads, or if it fails.
Change a font
- Pick a font on Fontsource and install its package: the variable one if it has one (
@fontsource-variable/<font>), else the static one (@fontsource/<font>). - Import its CSS file in your layout, as above. In a variable package the file name depends on the font's axes, such as
wght.cssoropsz.css. A static package has one file per weight, such as400.css. The package's page lists them. - Set the token in your site's CSS, after the preset import. For a variable font, name the family twice. End with system fallbacks:
:root {
--ui-font-display: "Fraunces", "Fraunces Variable", ui-serif, Georgia, serif;
}The display tokens tune how the new font sets: --ui-display-weight, --ui-display-track (letter spacing), --ui-display-stretch (width, for fonts with a width axis) and --ui-display-case.
Tip
Try fonts in Create first. Its font menus hold every preset font and more, such as Fraunces, Archivo, Karla and Young Serif. Copy CSS adds a comment that names the Fontsource files to import.
Your own headings
To make a heading of your own match the kit, use the display-face class for large display text and heading-face for small headings. Both read the display tokens, so they follow the preset.