Skip to content

The Golden Ratio

The Constant

φ=1+521.618033988749895

The Golden Ratio is the unique positive number where the ratio of the whole to the larger part equals the ratio of the larger part to the smaller:

a+ba=ab=φ

Why φ for a CSS framework?

Most design systems use either a linear scale (e.g., 4px, 8px, 12px, 16px...) or an arbitrary modular scale. Both require human decisions at every step.

The Golden Ratio scale is self-consistent: there are no decisions to make once you commit to φ. Every step follows mathematically from the previous. When two elements need visual separation, there is exactly one correct answer: the next step up.

The Scale

remCSS stores φ as a single CSS custom property and derives all other steps via calc():

css
:root {
	--phi: 1.618033988749895;
	--step-0: 1rem;
	--step-1: calc(var(--step-0) * var(--phi)); /* ≈ 1.618rem */
	--step-2: calc(var(--step-1) * var(--phi)); /* ≈ 2.618rem */
	/* ... */
}

This means the entire scale is live. If you change --phi on any element, all descendant spacing, type, and layout values recompute automatically.

Full Scale Reference

Tokenφ exponentValue (rem)Value (@10px root)
--step-n3φ⁻³0.23612.36px
--step-n2φ⁻²0.38203.82px
--step-n1φ⁻¹0.61806.18px
--step-0φ⁰1.000010.00px
--step-1φ¹1.618016.18px
--step-2φ²2.618026.18px
--step-3φ³4.236142.36px
--step-4φ⁴6.854168.54px
--step-5φ⁵11.090110.9px
--step-6φ⁶17.944179.4px
--step-7φ⁷29.034290.3px
--step-8φ⁸46.979469.8px
--step-9φ⁹76.013760.1px
--step-10φ¹⁰122.991230px
--step-11φ¹¹199.011990px
--step-12φ¹²322.003220px

Semantic Aliases

For component authors who don't want to think in steps, semantic aliases map intent to scale positions:

TokenStepApprox.
--space-xsn20.382rem
--space-smn10.618rem
--space-md01.000rem
--space-lg11.618rem
--space-xl22.618rem
--space-2xl34.236rem
--space-3xl46.854rem

Fluid Type

Text sizes use clamp() to interpolate smoothly between adjacent GR steps as the viewport grows:

size=clamp(stepn,f(viewport),stepn+1)
css
--text-base: clamp(var(--step-1), 1.3rem + 1vi, var(--step-2));

At narrow viewports, text locks to --step-1 (≈16px). At wide viewports, it approaches --step-2 (≈26px). The browser interpolates via the viewport expression in between.

Local Scale Override

Because all steps are calculated from --phi via calc(), you can create a locally denser or looser scale on any element:

css
.compact-card {
	/* Compress the scale — steps are smaller within this context */
	--phi: 1.4;
}

.hero-section {
	/* Expand the scale — more dramatic spacing */
	--phi: 1.8;
}