Back to Blog
March 16, 2026·1 min read
Choose Typography with Env Toggles, Not Endless Debates
We shipped a font switch driven by env vars so we could evaluate Inter vs. DM Sans in the real UI without churn. Here’s why it worked.
The lesson from env-toggled fonts
- Debating typography in design tools stalled; flipping NEXT_PUBLIC_FONT_CHOICE let us evaluate options in live context.
- Seeing type in the actual layout surfaced contrast and weight issues faster than comps.
- The toggle kept the codebase honest: no layout shift and no forced downloads while testing.
How we implemented it quickly
- Bound the chosen font to a single CSS token (`--font-primary`) so Tailwind classes updated automatically.
- Kept system sans as a zero-cost default while letting env flags opt into Inter or DM Sans when installed.
- Avoided new dependencies or build steps; decisions stay reversible until we commit.
When to use this trick
- You're unsure whether a web font is worth the performance trade.
- Stakeholders need to compare readability in dark and light themes on real devices.
- You want to prototype visual choices without polluting PRs with half-decisions.