Skip to content

[docs-infra] Use font variables on body - #49460

Merged
Janpot merged 2 commits into
mui:masterfrom
Janpot:docs-font-variables
Oct 14, 2026
Merged

Janpot merged 2 commits into
mui:masterfrom
Janpot:docs-font-variables

Conversation

@Janpot

@Janpot Janpot commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #49455. Put the next/font .variable classes on <body> instead of the .className classes, and drop the special case for General Sans.

A next/font className sets font-family, and for loaders with a single file also font-weight and font-style. Placing those classes on <body> let them override CssBaseline (they are unlayered, CssBaseline is in @layer mui), which is how General Sans 600 leaked into body text. Any future single-file loader would bring that back. The docs never rely on these classes: the themes reference the fonts by family name, and the _app re-export is what puts the font CSS in the bundle. A .variable class only defines a custom property, so it can't change rendering in either bundler.

What changes on the page: body text now takes its font from CssBaseline instead of whichever font class came last in the stylesheet. On docs pages that is the same IBM Plex Sans. The full page templates now get the body font from their own theme as intended. Internal /performance and /experiments pages render no CssBaseline, so plain text there falls back to the browser default font.

The variables (--font-ibm-plex-sans, --font-general-sans, --font-inter, --font-roboto) are not consumed yet. They point at the … Fallback faces Next generates with matched metrics, which the theme could use to reduce layout shift while fonts load. Under Turbopack the variable values use the JS binding name instead of the declared family (vercel/next.js#88894), so a theme change should list the family name first, for example "General Sans", var(--font-general-sans), ….

@code-infra-dashboard

code-infra-dashboard Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Deploy preview

https://deploy-preview-49460--material-ui.netlify.app/
QR code for https://deploy-preview-49460--material-ui.netlify.app/

Bundle size

Bundle Parsed size Gzip size
@mui/material 0B(0.00%) 0B(0.00%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/private-theming 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

@Janpot
Janpot marked this pull request as ready for review October 14, 2026 09:25
@Janpot
Janpot requested review from LukasTy and brijeshb42 October 14, 2026 09:25
@Janpot
Janpot merged commit 30cc58d into mui:master Oct 14, 2026
19 checks passed
@LukasTy

LukasTy commented Oct 14, 2026

Copy link
Copy Markdown
Member

Thanks for following up on this. 🙏

Codex insights

Optional follow-up: the docs body now uses CssBaseline's system fallback stack instead of Next's metric-adjusted IBM Plex Sans fallback. Loaded typography is preserved, but loading-time layout behavior could differ. Consuming the font variables in the theme could restore the adjusted fallback; CLS was not measured in this review. The linked Next.js #88894 is a separate font-family naming mismatch to account for when consuming those variables.

@zannager zannager added the scope: docs-infra Involves the docs-infra product (https://www.notion.so/mui-org/b9f676062eb94747b6768209f7751305). label Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: docs-infra Involves the docs-infra product (https://www.notion.so/mui-org/b9f676062eb94747b6768209f7751305).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants