
Variable fonts compress many styles into a single file, unlocking smoother theming, micro‑interactions, and finer typographic control with fewer requests. Yet production adoption requires careful planning around formats, fallbacks, and performance. This guide distills the practical steps to deploy variable fonts confidently.
Avoid them when you only need a single static style or when your audience includes very old browsers with no @supports(font-variation-settings) fallback.
WOFF2 variable font. Best compression and coverage in evergreen browsers.WOFF2 subset for legacy edge cases.WOFF or TTF static for niche environments.Use a progressive enhancement strategy:
/* Base: static fallback (optional) */
@font-face {
font-family: "Acme";
src: url("/fonts/acme-regular.woff2") format("woff2");
font-weight: 400;
font-style: normal;
font-display: swap;
}
/* Enhanced: variable font */
@supports (font-variation-settings: normal) {
@font-face {
font-family: "Acme";
src: url("/fonts/Acme-VF.woff2") format("woff2");
font-weight: 200 900; /* range */
font-stretch: 75% 125%;
font-style: normal;
font-display: swap;
}
}
Common registered axes:
wght (Weight): 200–900 typical.wdth (Width): 75–125% typical.ital/slnt (Italic/Slant): Italic switch or continuous slant.opsz (Optical Size): Size‑aware shapes for small vs large text.Recommendations:
opsz when the family provides it; it improves small‑text readability.wdth on paragraph text. Reflows cause layout jank, so restrict this to headlines.font-variation-settings for fine control, but set CSS longhands (font-weight, font-stretch) for compatibility.font-display: swap to prevent FOIT; combine with a tuned fallback stack.Example preload:
<link rel="preload" as="font" href="/fonts/Acme-VF.woff2" type="font/woff2" crossorigin>
Leverage CSS custom properties to unify design tokens and font axes:
:root {
--wght: 500;
}
h1 { font-weight: var(--wght); }
.button:hover { font-variation-settings: "wght" 650; }
For motion, prefer short durations (120–180ms) and ease‑out curves. Avoid animating body text properties that affect metrics.
prefers-reduced-motion) to disable animated axis changes.wdth for paragraphs.font-weight numeric values map to the intended glyphs (some VFs have uneven mapping).Photo by Markus Spiske on Pexels