WordPress theme.json vs. CSS Custom Properties: Building Fluid Typography Systems with clamp()
1. Replacing Rigid Breakpoint Media Queries With Fluid clamp() Scales
Traditional WordPress stylesheets define five separate @media breakpoints just to step an <h1> down from 72px on desktop to 36px on mobile. Modern CSS clamp(min, preferred, max) computes smooth, continuous scaling across every viewport width in a single line.
Whether you declare tokens in Gutenberg’s theme.json or directly inside your theme’s :root stylesheet, pairing fluid clamp() typography with calibrated line-height ratios (1.0–1.1 for display headings, 1.55–1.75 for long-form prose) keeps layouts balanced on tablets, foldables, and ultrawide monitors alike.

:root {
--text-display: clamp(2.4rem, 5.5vw, 4.8rem);
--text-h2: clamp(1.6rem, 3vw, 2.6rem);
--text-body: clamp(1rem, 1.1vw, 1.08rem);
}
2. Dark Mode & High-Contrast Palette Tokens Without Specificity Wars
Defining semantic surface tokens (--bg, --surface, --line, --ink, --accent) instead of hardcoding hex values inside 40 component selectors makes maintaining theme variants effortless. In hybrid PHP themes, you can even expose key accent tokens via Customizer CSS variables injected cleanly into wp_add_inline_style().
FAQ — Does CSS clamp() hurt older mobile browsers? No; CSS clamp() has over 97% global browser support across iOS Safari, Android Chrome, Edge, and Firefox.