Variable Fonts for UI Design: Axes and Patterns

Variable Fonts for UI Design: Axes and Patterns

The font-variation-settings property reached Baseline in 2018 — one variable file replaces several static weights with continuous axes. The CSS API, the subsetting pattern, and where the design payoff lives.

The font-variation-settings property reached Baseline Newly available in September 2018, and current versions of Chrome, Edge, Firefox, and Safari all support it. The practical effect of variable fonts is one font file in place of several static weight files, with continuous axes such as weight, width, slant, and optical size, depending on which axes the font includes. The byte savings depend on how many static files the variable file replaces and on how it is subsetted. Use the high-level CSS properties (font-weight, font-stretch, font-style) for the common cases and reserve font-variation-settings for custom axes and manual optical-size overrides. This guide covers the axes a designer actually uses, the performance pattern, and the four places variable fonts genuinely change product UI.

Variable fonts stopped being a forward-looking platform feature several years ago. They are the default that any product UI shipping in 2026 should be choosing against, not toward. The interesting decisions are no longer "do we use them" but which axes to expose as design tokens, how to keep the file from ballooning across scripts, and where the design payoff is actually worth the integration work.

This article is part of the web UX patterns guide. It covers the working detail of variable fonts in product UI; the typography fundamentals — type scale, line-height, rhythm — sit in the type scale and modular systems article.

What changed with variable fonts

A traditional type family ships as a set of files — one per weight, one per style, sometimes one per width. A four-weight roman plus four-weight italic family is eight files. A full nine-weight superfamily with italics and condensed variants reaches eighteen or more. Every weight you reference loads its own file.

A variable font ships as one file that interpolates along whichever axes its designer built in — registered axes such as weight, width, slant, italic, and optical size, plus any custom axes — inside the font itself. The same family that needed eight files can become one. How much you save depends on how many static weights the family used to ship and how the variable file is subsetted. The savings are not automatic — a poorly subsetted variable font with the full Latin Extended plus Cyrillic plus Greek glyph set can end up larger than the one or two subsetted static weights a page might otherwise load — but the ceiling is genuinely lower.

The other change is continuous selection. A static family supports the specific weights it shipped — 400, 500, 700. A variable font supports any weight within its own weight-axis range, which differs by font (Recursive's runs from 300 to 1000), including non-canonical values like 425 or 540. Designers who want a slightly heavier subhead than 500 but lighter than 600 can pick the exact value instead of negotiating with a static type rack.

The OpenType specification registers five axes:

AxisTagCSS propertyTypical range
Weightwghtfont-weight100–900
Widthwdthfont-stretch50–200 (percent)
Slantslntfont-style: oblique Xdeg0 to 20 degrees (slnt 0 to -20)
Italicitalfont-style: italic0 or 1
Optical sizeopszfont-optical-sizingfont-size dependent

Some typefaces expose custom axes beyond these five. Recursive ships a MONO axis for monospace-to-proportional interpolation; Roboto Flex has thirteen axes, nine of them custom, including XOPQ for the thickness of thick strokes such as stems. The v-fonts.com playground lets you browse and try variable fonts axis by axis before committing to one.

The axes a designer actually uses

In product UI, weight and optical size are the two axes this guide leans on; the other three suit narrower cases.

Weight (wght) handles hierarchy. One workable pattern is 400 for body, 500 for emphasis or active state, 600 for subheads and card titles, 700 for section headings, and 800 or 900 reserved for display. A variable font lets a designer experiment with intermediate values without changing the file load — font-weight: 450 for navigation labels that need slight emphasis without going full medium is one example.

Optical size (opsz) handles legibility across sizes. Without optical sizing, the same letterforms render at 12 CSS pixels and 96 CSS pixels — strokes that look balanced at large sizes look thin and brittle at caption sizes. Optical-size axes let the design change with size; as CSS Fonts 4 notes, to aid reading at small text sizes, strokes are often thicker with larger serifs, while larger text often has a more delicate figure with more contrast between thicker and thinner strokes. The CSS hook is font-optical-sizing: auto, under which the user agent may modify glyph shapes based on the font-size and the pixel density of the screen (for OpenType and TrueType variable fonts, often through the opsz axis); a note in CSS Fonts 4 says user agents are expected to supply an opsz value close to the used font-size, though they might also weigh other factors such as the screen's pixel density or the solid angle the text subtends in the viewer's retina. auto is the initial value, so it already applies unless something in your stack sets font-optical-sizing: none.

Width (wdth) handles density. A narrower setting fits more characters per line on mobile or in data tables; a wider setting opens up display headlines and editorial layouts. Width is easy to overlook because it requires a deliberate design decision per surface, not a global setting.

Slant (slnt) and italic (ital) look similar but differ in kind. A slant axis leans the upright design. Unlike the mechanical skew a browser may synthesize when no italic or oblique face is available, it is drawn by the type designer and can change letterforms too: in Recursive, with its Cursive (CRSV) axis at the default setting, slanting past -13.99 switches in cursive forms such as the single-story a and g. Italic is a designed variant with different letter shapes (cursive a, single-story g in many typefaces). For technical content where italic carries a specific meaning — variable names, foreign terms — italic is the right choice. For decorative slant in marketing UI, slant is fine.

CSS: font-weight, font-stretch, font-variation-settings

The CSS API for variable fonts has two layers. The high-level layer maps directly to the registered axes; the low-level layer exposes everything.

css
/* High-level — prefer this for registered axes */
.subhead {
  font-weight: 550;          /* wght axis */
  font-stretch: 95%;         /* wdth axis */
  font-style: oblique 10deg; /* slnt axis */
  font-optical-sizing: auto; /* opsz axis */
}

/* Low-level — use for custom axes and opsz override */
.subhead {
  font-variation-settings: "opsz" 24, "GRAD" 50;
}

The high-level properties are the right default for two reasons. They cascade — font-weight: 700 on a parent affects nested elements — while font-variation-settings does not cascade by axis; it replaces the whole declaration. And they integrate with the strong and em semantic elements, and the rest of the user-agent stylesheet, which uses semantic properties, not variation settings.

font-variation-settings becomes the right tool for two cases. Custom axes — GRAD for grade, MONO for monospace interpolation, the many flex axes in Roboto Flex — have no high-level mapping. And manual optical-size override, when you want to apply a different optical-size variant than font-size would imply (a small display headline that needs the large optical-size treatment).

Animation works on both layers. A hover state that lifts weight from 400 to 500 looks smooth with transition: font-variation-settings 200ms ease when both states declare the same set of axes, in any order (for example, "wght" 400 and "wght" 500): the browser then interpolates the axis value continuously, not stepping through discrete weights. If the two declarations list different axes, CSS Fonts 4 does not interpolate them — the value is swapped at an unspecified time during the animation — so for weight alone, transitioning font-weight avoids the issue. The MDN variable fonts guide covers the axes and @font-face usage in detail, and the W3C CSS Fonts Module Level 4 specification, a W3C Working Draft as of November 2026, defines the property semantics, including that interpolation rule.

Performance: variable fonts done right

Variable fonts are not automatically smaller. A single file containing every Latin glyph plus Latin Extended plus Cyrillic plus Greek plus full punctuation can grow large: as web.dev's Best practices for fonts notes, variable fonts contain many styles, so they typically have larger file sizes than individual single-style static fonts, and such a file can outweigh the one or two subsetted static weights a page might otherwise load. Deliberate subsetting keeps that size down.

One subsetting pattern is a separate @font-face per script range, each with its own unicode-range:

css
@font-face {
  font-family: "BrandSans";
  src: url("brandsans-vf.latin.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 75% 125%;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153,
                 U+02BB-02BC, U+02C6, U+02DA, U+02DC,
                 U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193;
}

@font-face {
  font-family: "BrandSans";
  src: url("brandsans-vf.latin-ext.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 75% 125%;
  font-display: swap;
  unicode-range: U+0100-024F, U+0259, U+1E00-1EFF;
}

@font-face {
  font-family: "BrandSans";
  src: url("brandsans-vf.cyrillic.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 75% 125%;
  font-display: swap;
  unicode-range: U+0400-045F;
}

The plain woff2 format hint is enough for a variable file; the older woff2-variations string is still accepted by CSS Fonts 4 for backwards compatibility, with the same effect as format(woff2) tech(variations), although the spec prefers keywords. The browser only downloads the subset whose unicode-range matches characters on the page. A page with only Latin content never fetches the Cyrillic subset. This example uses font-display: swap — show fallback text immediately, swap when the web font arrives. The trade-off is a brief flash of unstyled text (FOUT), which is preferable to a flash of invisible text (FOIT) on slow connections. CSS Fonts 4, though, says swap should only be used for small pieces of text where rendering in that particular font is very important for the page but any font still gets the message across, such as a logo; it recommends fallback for body text or other text where the chosen font is useful and desired but a fallback font is acceptable, and optional for body text or other text where the chosen font is purely a decorative nice-to-have, so choose the value per face.

Preload the body font first; preload a display font when its text is the LCP element. A <link rel="preload" as="font" href="brandsans-vf.latin.woff2" crossorigin> in the document head starts the font request before the stylesheet is parsed, which helps largest contentful paint on pages where body text is the LCP element. A display font sits on the LCP path when text set in it is the LCP element — for example, a large headline that is the largest element in view. Preloading it otherwise takes browser resources away from other downloads, as web.dev's font guidance cautions, so check which element is the LCP element before preloading it.

Test on a throttled connection. For illustration, a variable font that takes 800 milliseconds to fetch on slow 3G is worse than a static font that takes 200 milliseconds, even if the static font ships 80 kilobytes more across the eventual full session. The web.dev guide to variable fonts covers the loading patterns in working detail.

Fallback and progressive enhancement

The font-variation-settings property reached Baseline Newly available on September 5, 2018, and font-optical-sizing followed on March 24, 2020; the font-variation-settings descriptor inside @font-face is not Baseline (as of Nov 2026, web-features). Current versions of Chrome, Edge, Firefox, and Safari support both properties. The @supports (font-variation-settings: normal) query exists; the browsers it filters out are those without the property — Internet Explorer and older versions of the others, such as Safari before 11 (or on macOS before 10.13), Safari on iOS before 11, Chrome and Firefox before 62, and EdgeHTML-based Edge before 17 — and these should not be the primary design target.

One defensive pattern is a system-font fallback. While the variable font loads, the page renders in a system stack — -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, depending on platform. When the web font arrives, the swap happens. Layout shift during the swap can be reduced with the size-adjust, ascent-override, and descent-override descriptors on a separate @font-face rule that wraps the local fallback font (src: local(...)): they adjust the fallback's metrics toward the web font's, so the line-height jumps less on swap. Browser support differs: size-adjust works in Chrome, Firefox, and Safari 17 and later, while ascent-override and descent-override work in Chrome and Firefox but, as of November 2026, only in Safari Technology Preview (MDN browser compatibility).

One trap is animation. A transition on font-variation-settings works when the variable font is loaded and both states list the same axes, but if the page renders in fallback first and the transition fires before the variable font arrives, nothing animates when the fallback font lacks those axes — CSS ignores axis settings a font does not support and does not synthesize a substitute. Either gate animations on the fonts.ready promise or accept that the first hover does nothing on slow connections.

Where variable fonts shine in UI

Variable fonts are not interesting because they save bytes. They are interesting because they expose design choices the static-file model could not.

Hover and focus weight changes on navigation labels — body weight at rest, medium on hover, semibold on the active item — produce subtle hierarchy without changing color or font size. Heavier weights can set wider, though, and a wider label can push neighboring items; when the layout must not move, reserve the label's width or, if the font has one, use a grade axis such as GRAD, which does not change the space the text occupies. A 200-millisecond transition on font-weight interpolates continuously through the axis instead of stepping through the discrete weights the static file would have shipped.

Animated headline reveals interpolate weight or width on scroll or entry. The animation-timeline: view() syntax (Baseline Newly available since October 2026, as of Nov 2026, web-features) from the scroll-driven animation pattern lets a marketing headline grow from font-stretch: 75% to 100% as it enters the viewport, without a JavaScript scroll library.

Reading-mode toggles — narrow, standard, wide — switch the width axis on body text. For example, long-form articles might render at font-stretch: 95% by default; users who want denser scanning toggle to 90% for more content per line. The same variable font handles both with no extra file load.

Density-aware product UI shifts width and weight together by container size. For example, a data table inside a narrow sidebar might use font-stretch: 92% and font-weight: 425 for compactness; the same table in a full-width view might use 100% and 450 for readability. Size container queries (Baseline 2023) let you bind these to component width directly.

These four cases are not exhaustive, but they are the patterns where the integration cost — choosing the typeface, subsetting it, training designers on the axes — is worth the payoff. The rest of the time, a variable font is a quiet upgrade that nobody notices, which is also fine.

Diagnostic checklist for the next planning cycle

  • Replace your existing static weight files with one variable font, subsetted by script.
  • If your variable font has an opsz axis, confirm nothing in your stack sets font-optical-sizing: none (auto is the initial value).
  • Identify two surfaces — navigation hover, headline reveal, reading mode, or density-aware table — where a continuous axis adds clear value.
  • Preload the body subset; preload a display subset when its text is the LCP element.
  • Verify size-adjust and the override pair are set on the fallback's @font-face rule to minimize cumulative layout shift on swap.
  • Test on throttled slow 3G; if first-paint typography is unreadable, the subsetting is wrong.

Variable fonts are the typography platform of 2026, not a future technology. The integration is straightforward; the design payoff is real on the surfaces that earn it.

Project Inquiry