Free guideThe newsletter. Real UI fixes by email, and a free 35-page guide to AI design skills.
Ship Better UI

, 1 minute 20 seconds

What spacing values should you use in a UI?

The rule

Make every gap a multiple of 4 and pick it from a short scale (4, 8, 16, 24): 8 px inside a group, 24 px between groups, each step named as a token, like space-6 for 24 px.

Try it

Apply the fix

Prompt for your AI coding tool

Paste it into Claude Code, Cursor or any AI coding tool, then share the page you want fixed.

Review the interface I share for spacing picked by eye. Put every gap on one scale in steps of 4, and change nothing else.

1. Grid: snap every padding, margin and gap to a multiple of 4 px (15 becomes 16, 3 becomes 4), so every edge lands on a 4 px grid line.
2. Scale: keep a short list of allowed sizes: 4, 8, 16 and 24 px. Use 8 px inside a group and 24 px between groups, so the space shows what belongs together.
3. Tokens: name each step as a token (space-1 = 4 px, space-2 = 8 px, space-6 = 24 px) and use the tokens instead of typed numbers: margin-top: var(--space-6), not margin-top: 15px.

Keep the content, the features, the colours, the type and the line heights. When you are done, list each gap you changed (what it was, what it is now) and how many different spacing values there were before and after.

More prompts like this in the free guide 

The problem

The invite card in the video has a title, a subtitle, an Email field, a helper line and two buttons. Its padding, the space inside the edge, and the gaps between items were all picked by eye: 15, 3, 18, 6, 10, 22 and 17 px. That is seven different values, none of them related, and nothing quite lines up.

The fix

  1. Snap every gap to a 4 px grid. 15 becomes 16, 3 becomes 4, and every edge lands on a grid line.
  2. Keep a short scale. Allow only a few sizes: 4, 8, 16 and 24. Use 8 px inside a group and 24 px between groups.
  3. Name each step as a token. space-6 is 24 px, so the code says margin-top: var(--space-6), not margin-top: 15px.

Why it works

On a grid of 4 px squares, every edge lands on a line, so things line up without anyone measuring. The short scale lets the space mean something: the small gap holds a group together and the large gap keeps groups apart, so the space shows what belongs together. Tokens keep it that way. In the video, a teammate types 15 pixels and the drift is back. With names to pick from, nobody types a number. Seven values picked by eye become three, 4, 8 and 24, all from one scale in steps of four.

How to apply it

Write your scale down as tokens and use only those. Then go through a screen gap by gap: snap each value to the grid, use 8 px inside a group and 24 px between groups, and replace every typed number with its token.

Free guide · 35 pages

Get fixes like this by email

Join the newsletter and get the 35-page guide to AI design skills: the skills, the order to use them in, and prompts to copy.

Watch it on

More on space