The Journal

Interface Craft3 min read

Spacing Systems: Why Your UI Looks Off (And How to Fix It)

Inconsistent spacing is the #1 reason UIs look unprofessional. Here's how to set up a spacing system that makes everything look clean and aligned.

Open any rough UI and the problem is almost always spacing. 13px here, 20px there, 6px somewhere else — nothing lines up, and the whole thing feels sloppy without anyone knowing why. The fix isn’t taste. It’s a scale, and it takes an hour to set up.

Multiples of four

Pick one base unit and multiply it. Four works because it divides cleanly and still gives you fine control at the small end. Every margin, padding, and gap becomes a multiple: 4, 8, 12, 16, 24, 32, 48, 64px. If a value isn’t on that list, it’s a bug, not a decision. Skip odd bases like 5 or 6 — halves and quarters stop landing on whole pixels and edges start to look fuzzy. Tailwind’s default spacing already works this way — one unit equals 4px.

Five values, not twenty

You don’t need every multiple. Most interfaces run on about six spacing values, and reaching for a seventh usually means two elements should share one. Fewer options make every layout call faster and more consistent. Name them once as tokens and stop typing raw numbers. Cut the options and you spend less time deciding spacing and more time shipping it.

globals.css
:root {
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
}

Gap over margin

Stop pushing elements around with margins. Set the parent to display: flex or grid and control the rhythm with gap. One property spaces every child evenly — no margin-collapsing surprises, no leftover space clinging to the last item. When spacing lives on the container, adding or removing a child never breaks the layout. It also makes responsive work trivial: change one gap value at a breakpoint and the whole row reflows on its own.

Ship it

Delete every hard-coded spacing value and swap in a token from your six-step scale. Lay out with gap, not margins. Do that and alignment stops being something you eyeball — it falls out of the system for free, on every screen you build after this one. Six values, one base, spacing on the container — that’s the whole system.

Frequently asked questions

How do I fix inconsistent spacing that makes my UI look off?
Build every margin, padding, and gap on one base unit multiplied out, typically 4px giving 4, 8, 12, 16, 24, and 32px. Eyeballed, off-scale values are the main reason UIs look unprofessional, and a fixed scale makes alignment fall out of the system for free.
Should I use gap or margin for spacing in CSS?
Use gap. Set the parent to display: flex or grid and control rhythm with gap, which spaces every child evenly with no margin-collapsing surprises. When spacing lives on the container, adding or removing a child never breaks the layout, and responsive tweaks become a single value change.
Why is 4px a good base unit for a spacing system?
4px divides cleanly, gives fine control at the small end, and lands on whole pixels so edges stay crisp. Tailwind CSS uses this by default, where one spacing unit equals 4px. Odd bases like 5 or 6 push halves onto fractional pixels and make edges look fuzzy.