Spacing Scale Generator

Enter a base unit and ratio to generate a modular spacing scale with px, rem, and CSS custom property output.

Tailwind default is 4px. Common: 2, 4, 8, 10.

Each step = previous × ratio. 1 = linear.

Steps generated starting from the base (3–20).

Used to compute rem values. Browser default: 16px.

Scale Preview

base 4px · ratio 2 · 10 steps
Step Token px rem Visual

Code Output


        
Copied!

Summary

Enter a base unit and ratio to generate a modular spacing scale with px, rem, and CSS custom property output.

How it works

  1. Set the base unit in pixels (e.g. 4px is the Tailwind default).
  2. Choose a ratio multiplier to control how fast the scale grows.
  3. Set how many steps to generate above and below the base.
  4. Pick an output format: CSS custom properties, Tailwind config, or plain table.
  5. Click Copy to grab the output and paste it into your project.

Use cases

  • Generate a consistent 4px-grid spacing scale for a new design system.
  • Create modular spacing tokens with a custom ratio for tighter or looser layouts.
  • Export CSS custom properties to use as spacing variables across a stylesheet.
  • Preview rem values alongside px to ensure accessible sizing at any font size.
  • Compare linear vs. ratio-based scales side by side before committing to one.
  • Build a Tailwind-compatible spacing config with precise pixel increments.

Frequently Asked Questions

Last updated: 2026-07-01 · Reviewed by Nham Vu